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/gossip"
|
||||||
"github.com/micro/go-micro/registry/mdns"
|
"github.com/micro/go-micro/registry/mdns"
|
||||||
rmem "github.com/micro/go-micro/registry/memory"
|
rmem "github.com/micro/go-micro/registry/memory"
|
||||||
|
regSrv "github.com/micro/go-micro/registry/service"
|
||||||
|
|
||||||
// selectors
|
// selectors
|
||||||
"github.com/micro/go-micro/client/selector"
|
"github.com/micro/go-micro/client/selector"
|
||||||
@ -190,6 +191,8 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
|
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
|
||||||
|
"go.micro.registry": regSrv.NewRegistry,
|
||||||
|
"service": regSrv.NewRegistry,
|
||||||
"consul": consul.NewRegistry,
|
"consul": consul.NewRegistry,
|
||||||
"gossip": gossip.NewRegistry,
|
"gossip": gossip.NewRegistry,
|
||||||
"mdns": mdns.NewRegistry,
|
"mdns": mdns.NewRegistry,
|
||||||
|
@ -134,7 +134,14 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
|
|||||||
o(&options)
|
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()
|
mReg := registry.NewRegistry()
|
||||||
|
|
||||||
// create new client with mdns
|
// create new client with mdns
|
||||||
@ -149,7 +156,7 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
|
|||||||
return &serviceRegistry{
|
return &serviceRegistry{
|
||||||
opts: options,
|
opts: options,
|
||||||
name: name,
|
name: name,
|
||||||
address: options.Addrs,
|
address: addrs,
|
||||||
client: pb.NewRegistryService(name, cli),
|
client: pb.NewRegistryService(name, cli),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user