https://github.com/micro
1.下载
go get -u -v github.com/micro/micro/...
go get -u -v github.com/micro/go-micro/...
go get -u -v github.com/micro/go-plugins/...
2.编译
cd $GOPATH/pkg/mod/github.com/micro/ && ls |grep micro
选择对应的版本进入目录
cd micro@v1.18.0/
进行编译到/bin目录
sudo $GOROOT/bin/go build -o /bin/micro main.go
ls -la /bin/ | grep micro
3.插件安装
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
go get -u github.com/micro/protoc-gen-micro
cd $GOPATH/bin && ls -la | grep protoc
4.测试
micro --version
micro --help
NAME:
micro - A microservice runtime
USAGE:
micro [global options] command [command options] [arguments...]
VERSION:
1.18.0
COMMANDS:
api Run the api gateway
bot Run the chatops bot
cli Run the interactive CLI
call Call a service e.g micro call greeter Say.Hello '{"name": "John"}
services List the services in the network
stream Create a service stream
publish Publish a message to a topic
stats Query the stats of a service
list List items in registry or network
register Register an item in the registry
deregister Deregister an item in the registry
get Get item from registry
broker Run the message broker
health Run the http healthchecking sidecar at /health
proxy Run the service proxy
monitor Run the monitoring service
router Run the micro network router
tunnel Run the micro network tunnel
network Run the micro network node
registry Run the service registry
runtime Run the micro runtime
run Run a service e.g micro run service version
kill Kill removes a running service e.g micro kill service
ps Ps returns status of a running service or lists all running services e.g. micro ps
debug Run the micro debug service
logs Get logs for a service
server Run the micro network server
service Run a micro service
store Run the micro store service
token API token commands
new Create a service template
plugin Plugin commands
web Run the web dashboard
debug Run the micro debug service
logs Get logs for a service
init Run the micro operator
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--client value Client for go-micro; rpc [$MICRO_CLIENT]
--client_request_timeout value Sets the client request timeout. e.g 500ms, 5s, 1m. Default: 5s [$MICRO_CLIENT_REQUEST_TIMEOUT]
--client_retries value Sets the client retries. Default: 1 (default: 1) [$MICRO_CLIENT_RETRIES]
--client_pool_size value Sets the client connection pool size. Default: 1 (default: 0) [$MICRO_CLIENT_POOL_SIZE]
--client_pool_ttl value Sets the client connection pool ttl. e.g 500ms, 5s, 1m. Default: 1m [$MICRO_CLIENT_POOL_TTL]
--register_ttl value Register TTL in seconds (default: 60) [$MICRO_REGISTER_TTL]
--register_interval value Register interval in seconds (default: 30) [$MICRO_REGISTER_INTERVAL]
--server value Server for go-micro; rpc [$MICRO_SERVER]
--server_name value Name of the server. go.micro.srv.example [$MICRO_SERVER_NAME]
--server_version value Version of the server. 1.1.0 [$MICRO_SERVER_VERSION]
--server_id value Id of the server. Auto-generated if not specified [$MICRO_SERVER_ID]
--server_address value Bind address for the server. 127.0.0.1:8080 [$MICRO_SERVER_ADDRESS]
--server_advertise value Used instead of the server_address when registering with discovery. 127.0.0.1:8080 [$MICRO_SERVER_ADVERTISE]
--server_metadata value A list of key-value pairs defining metadata. version=1.0.0 [$MICRO_SERVER_METADATA]
--broker value Broker for pub/sub. http, nats, rabbitmq [$MICRO_BROKER]
--broker_address value Comma-separated list of broker addresses [$MICRO_BROKER_ADDRESS]
--profile value Debug profiler for cpu and memory stats [$MICRO_DEBUG_PROFILE]
--registry value Registry for discovery. etcd, mdns [$MICRO_REGISTRY]
--registry_address value Comma-separated list of registry addresses [$MICRO_REGISTRY_ADDRESS]
--runtime value Runtime for building and running services e.g local, kubernetes (default: "local") [$MICRO_RUNTIME]
--selector value Selector used to pick nodes for querying [$MICRO_SELECTOR]
--transport value Transport mechanism used; http [$MICRO_TRANSPORT]
--transport_address value Comma-separated list of transport addresses [$MICRO_TRANSPORT_ADDRESS]
--local Enable local only development
--enable_acme Enables ACME support via Let's Encrypt. ACME hosts should also be specified. [$MICRO_ENABLE_ACME]
--acme_hosts value Comma separated list of hostnames to manage ACME certs for [$MICRO_ACME_HOSTS]
--acme_provider value The provider that will be used to communicate with Let's Encrypt. Valid options: autocert, certmagic [$MICRO_ACME_PROVIDER]
--enable_tls Enable TLS support. Expects cert and key file to be specified [$MICRO_ENABLE_TLS]
--tls_cert_file value Path to the TLS Certificate file [$MICRO_TLS_CERT_FILE]
--tls_key_file value Path to the TLS Key file [$MICRO_TLS_KEY_FILE]
--tls_client_ca_file value Path to the TLS CA file to verify clients against [$MICRO_TLS_CLIENT_CA_FILE]
--api_address value Set the api address e.g 0.0.0.0:8080 [$MICRO_API_ADDRESS]
--proxy_address value Proxy requests via the HTTP address specified [$MICRO_PROXY_ADDRESS]
--web_address value Set the web UI address e.g 0.0.0.0:8082 [$MICRO_WEB_ADDRESS]
--network value Set the micro network name: local, go.micro [$MICRO_NETWORK]
--network_address value Set the micro network address e.g. :9093 [$MICRO_NETWORK_ADDRESS]
--router_address value Set the micro router address e.g. :8084 [$MICRO_ROUTER_ADDRESS]
--gateway_address value Set the micro default gateway address e.g. :9094 [$MICRO_GATEWAY_ADDRESS]
--tunnel_address value Set the micro tunnel address e.g. :8083 [$MICRO_TUNNEL_ADDRESS]
--api_handler value Specify the request handler to be used for mapping HTTP requests to services; {api, proxy, rpc} [$MICRO_API_HANDLER]
--api_namespace value Set the namespace used by the API e.g. com.example.api [$MICRO_API_NAMESPACE]
--web_namespace value Set the namespace used by the Web proxy e.g. com.example.web [$MICRO_WEB_NAMESPACE]
--enable_stats Enable stats [$MICRO_ENABLE_STATS]
--auto_update Enable automatic updates [$MICRO_AUTO_UPDATE]
--report_usage Report usage statistics [$MICRO_REPORT_USAGE]
--namespace value Set the micro service namespace (default: "go.micro") [$MICRO_NAMESPACE]
--plugin value Comma separated list of plugins e.g broker/rabbitmq, registry/etcd, micro/basic_auth, /path/to/plugin.so [$MICRO_PLUGIN]
--help, -h show help
--version, -v print the version