Merge pull request #783 from micro/service
Add flag for registry service client
This commit is contained in:
commit
be5799b09f
@ -30,6 +30,7 @@ import (
|
||||
"github.com/micro/go-micro/registry/gossip"
|
||||
"github.com/micro/go-micro/registry/mdns"
|
||||
rmem "github.com/micro/go-micro/registry/memory"
|
||||
regSrv "github.com/micro/go-micro/registry/service"
|
||||
|
||||
// selectors
|
||||
"github.com/micro/go-micro/client/selector"
|
||||
@ -190,10 +191,12 @@ var (
|
||||
}
|
||||
|
||||
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
|
||||
"consul": consul.NewRegistry,
|
||||
"gossip": gossip.NewRegistry,
|
||||
"mdns": mdns.NewRegistry,
|
||||
"memory": rmem.NewRegistry,
|
||||
"go.micro.registry": regSrv.NewRegistry,
|
||||
"service": regSrv.NewRegistry,
|
||||
"consul": consul.NewRegistry,
|
||||
"gossip": gossip.NewRegistry,
|
||||
"mdns": mdns.NewRegistry,
|
||||
"memory": rmem.NewRegistry,
|
||||
}
|
||||
|
||||
DefaultSelectors = map[string]func(...selector.Option) selector.Selector{
|
||||
|
@ -134,7 +134,14 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
// use mdns to find the service registry
|
||||
// the registry address
|
||||
addrs := options.Addrs
|
||||
|
||||
if len(addrs) == 0 {
|
||||
addrs = []string{"127.0.0.1:8000"}
|
||||
}
|
||||
|
||||
// use mdns as a fall back in case its used
|
||||
mReg := registry.NewRegistry()
|
||||
|
||||
// create new client with mdns
|
||||
@ -149,7 +156,7 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
|
||||
return &serviceRegistry{
|
||||
opts: options,
|
||||
name: name,
|
||||
address: options.Addrs,
|
||||
address: addrs,
|
||||
client: pb.NewRegistryService(name, cli),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user