Comments (10)
Seems you aren't using the etcd registry in the services call.
micro --registry etcd services
Extra info
You can add etcd with a noop import and then run the service with "--registry etcd", this allows easy switching of dependencies.
package main
import (
"go-micro.dev/v4"
"go-micro.dev/v4/logger"
"helloworld/handler"
pb "helloworld/proto"
_ "github.com/go-micro/plugins/v4/registry/etcd"
)
func main() {
// Create service
srv := micro.NewService(
micro.Name("helloworld"),
)
// Register handler
pb.RegisterHelloworldHandler(srv.Server(), handler.New())
// Run service
if err := srv.Run(); err != nil {
logger.Fatal(err)
}
}
Then:
micro run . --registry etcd
Same as:
go run main.go --registry etcd
This also configureable via ENV variables:
$ go run main.go --help
NAME:
helloworld - a go-micro service
USAGE:
helloworld [global options] command [command options] [arguments...]
COMMANDS:
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: 5) [$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 [ --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 [$MICRO_RUNTIME]
--runtime_source value Runtime source for building and running services e.g github.com/micro/service (default: "github.com/micro/services") [$MICRO_RUNTIME_SOURCE]
--selector value Selector used to pick nodes for querying [$MICRO_SELECTOR]
--store value Store used for key-value storage [$MICRO_STORE]
--store_address value Comma-separated list of store addresses [$MICRO_STORE_ADDRESS]
--store_database value Database option for the underlying store [$MICRO_STORE_DATABASE]
--store_table value Table option for the underlying store [$MICRO_STORE_TABLE]
--transport value Transport mechanism used; http [$MICRO_TRANSPORT]
--transport_address value Comma-separated list of transport addresses [$MICRO_TRANSPORT_ADDRESS]
--tracer value Tracer for distributed tracing, e.g. memory, jaeger [$MICRO_TRACER]
--tracer_address value Comma-separated list of tracer addresses [$MICRO_TRACER_ADDRESS]
--auth value Auth for role based access control, e.g. service [$MICRO_AUTH]
--auth_id value Account ID used for client authentication [$MICRO_AUTH_ID]
--auth_secret value Account secret used for client authentication [$MICRO_AUTH_SECRET]
--auth_namespace value Namespace for the services auth account (default: "go.micro") [$MICRO_AUTH_NAMESPACE]
--auth_public_key value Public key for JWT auth (base64 encoded PEM) [$MICRO_AUTH_PUBLIC_KEY]
--auth_private_key value Private key for JWT auth (base64 encoded PEM) [$MICRO_AUTH_PRIVATE_KEY]
--config value The source of the config to be used to get configuration [$MICRO_CONFIG]
--help, -h show help
from go-micro.
when i run micro --registry etcd services
, error occurred:flag provided but not defined: -registry
, the command output below:
knight@knightdeMacBook-Pro helloworld % micro --registry etcd services
Incorrect Usage. flag provided but not defined: -registry
NAME:
micro - API first development platform
USAGE:
micro [global options] command [command options] [arguments...]
VERSION:
v4.3.1
COMMANDS:
auth Manage authentication, accounts and rules
call Call a service e.g micro call greeter Say.Hello '{"name": "John"}'
config Manage configuration values
env Get/set micro cli environment
gen Generate a micro related dependencies e.g protobuf
get Get resources from micro
init Generate a profile for micro plugins
kill Kill a service: micro kill [source]
login Interactive login flow.
logout Logout.
logs Get logs for a service e.g. micro logs helloworld
new Create a service template
run Run a service: micro run [source]
server Run the micro server
service
services List services in the registry
shutdown Shutdown a micro server
status Get the status of services
store Commands for accessing the store
stream Create a service stream e.g. micro stream foo Bar.Baz '{"key": "value"}'
update Update a service: micro update [source]
user Print the current logged in user
web Run the micro web UI
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
-c value Set the config file: Defaults to ~/.micro/config.json [$MICRO_CONFIG_FILE]
--env value, -e value Set the environment to operate in [$MICRO_ENV]
--namespace value Namespace the service is operating in (default: "micro") [$MICRO_NAMESPACE]
--client_id value Account ID used for client authentication [$MICRO_CLIENT_ID]
--client_secret value Account secret used for client authentication [$MICRO_CLIENT_SECRET]
--public_key value Public key for JWT auth (base64 encoded PEM) [$MICRO_PUBLIC_KEY]
--private_key value Private key for JWT auth (base64 encoded PEM) [$MICRO_PRIVATE_KEY]
--name value Set the service name [$MICRO_SERVICE_NAME]
--profile value Set the micro server profile: e.g. local or kubernetes [$MICRO_SERVICE_PROFILE]
--network value Service network address [$MICRO_SERVICE_NETWORK]
--help, -h show help (default: false)
--version, -v print the version (default: false)
Flag provided but not defined: -registry
from go-micro.
Micro v4 is not compatible with go-micro
from go-micro.
Micro v4 is not compatible with go-micro
how can i registry a service to the micro server? any docs about that?
from go-micro.
Go to micro.dev and read the docs there. Effectively import micro.dev/v4/service and use "micro run [repo]"
from go-micro.
Go to micro.dev and read the docs there. Effectively import micro.dev/v4/service and use "micro run [repo]"
Micro v4 is not compatible with go-micro
so there is not a way to registry a service to the go-micro with Micro v4:
import "go-micro.dev/v4"
func main() {
etcdReg := etcd.NewRegistry(registry.Addrs(":2379"))
// Create service
srv := micro.NewService(
micro.Name("greeterService"),
micro.Address(":6666"),
micro.Registry(etcdReg),
)
}
if i want to registry a service to micro server, the only way is use the import "micro.dev/v4/service"
?
from go-micro.
That's correct they are now two separate projects
from go-micro.
That's correct they are now two separate projects
what the different between these and which one i should use?
from go-micro.
One is a platform. The other is a framework. Use go-micro if you want to piece everything together yourself.
from go-micro.
Use go-micro if you want to piece everything together yourself.
thanks! it's clear.
from go-micro.
Related Issues (20)
- trying to send message larger than max (14547977 vs. 4194304) ? HOT 1
- panic: qtls.ConnectionState not compatible with tls.ConnectionState
- [BUG] Version V2.9.1 CLI no longer exists HOT 5
- grpc stream use async socket send, but seem use them same buffer, the newer msg seems overwrite the underlying buffer HOT 4
- Tag latest v3 changes (v3.7.2) HOT 1
- [go-micro/auth.Inspect()] Is this function working? HOT 2
- how can i writter log to file? HOT 4
- how can i pass http request headers through metadata?
- [BUG] go.micro.client.transport write: broken pipe
- [BUG] for v4.9.0 to RegisterSubscriber with Queue
- go-micro v4版本 客户端请求超时,,在go-micro怎么配置请求时间 HOT 2
- v4 v4.10.2 can't subscribe kafka topic anymore? HOT 1
- call Requset Timeout with detail <nil> HOT 2
- Using rabbitmq as broker in service , fail to publish mq message with " service not found" HOT 1
- Doesn't go-micro support lowercase grpc method name in proto ? HOT 1
- Client-side Retries mechanism causes server-side code to be called multiple times HOT 1
- [BUG] v2 has no dependency to github.com/micro/cli/v2 v2.1.2 HOT 1
- [BUG] v4.9.0 rpc_server.go register function read lock re-entry HOT 1
- [BUG]V4.10.2 rpc_client.go Call function easily happen RWMutex‘s read lock re-entry then deadlock HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-micro.