add cmd and bug fix
This commit is contained in:
parent
8706aa4a46
commit
72d8dc89fb
@ -20,6 +20,7 @@ import (
|
|||||||
// registries
|
// registries
|
||||||
"github.com/micro/go-micro/registry"
|
"github.com/micro/go-micro/registry"
|
||||||
"github.com/micro/go-micro/registry/consul"
|
"github.com/micro/go-micro/registry/consul"
|
||||||
|
"github.com/micro/go-micro/registry/gossip"
|
||||||
"github.com/micro/go-micro/registry/mdns"
|
"github.com/micro/go-micro/registry/mdns"
|
||||||
|
|
||||||
// selectors
|
// selectors
|
||||||
@ -171,6 +172,7 @@ var (
|
|||||||
|
|
||||||
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
|
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
|
||||||
"consul": consul.NewRegistry,
|
"consul": consul.NewRegistry,
|
||||||
|
"gossip": gossip.NewRegistry,
|
||||||
"mdns": mdns.NewRegistry,
|
"mdns": mdns.NewRegistry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ type gossipRegistry struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultPort = 8118
|
// defaults to random port
|
||||||
|
defaultPort = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
type broadcast struct {
|
type broadcast struct {
|
||||||
@ -349,6 +350,7 @@ func (g *gossipRegistry) run() error {
|
|||||||
RetransmitMult: 3,
|
RetransmitMult: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.queue = d.queue
|
||||||
g.memberlist = m
|
g.memberlist = m
|
||||||
g.delegate = d
|
g.delegate = d
|
||||||
d.registry = g
|
d.registry = g
|
||||||
@ -365,11 +367,13 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
|
|||||||
|
|
||||||
g := &gossipRegistry{
|
g := &gossipRegistry{
|
||||||
opts: options,
|
opts: options,
|
||||||
|
services: make(map[string][]*registry.Service),
|
||||||
}
|
}
|
||||||
if err := g.run(); err != nil {
|
if err := g.run(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Logf("Registry gossiping at %s", g.memberlist.LocalNode().Address())
|
||||||
// return gossip registry
|
// return gossip registry
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user