Call advertise
This commit is contained in:
parent
67e3d560fe
commit
b4b76d452a
@ -131,6 +131,8 @@ func (p *Proxy) getRoute(service string) ([]string, error) {
|
|||||||
// no router is specified we're going to set the default
|
// no router is specified we're going to set the default
|
||||||
if len(name) == 0 && len(addr) == 0 {
|
if len(name) == 0 && len(addr) == 0 {
|
||||||
p.Router = router.DefaultRouter
|
p.Router = router.DefaultRouter
|
||||||
|
go p.Router.Advertise()
|
||||||
|
|
||||||
// recursively execute getRoute
|
// recursively execute getRoute
|
||||||
return p.getRoute(service)
|
return p.getRoute(service)
|
||||||
}
|
}
|
||||||
@ -170,7 +172,7 @@ func (p *Proxy) getRoute(service string) ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pbRoutes *pb.LookupResponse
|
var pbRoutes *pb.LookupResponse
|
||||||
var err error
|
var gerr error
|
||||||
|
|
||||||
// set default client
|
// set default client
|
||||||
if p.RouterService == nil {
|
if p.RouterService == nil {
|
||||||
@ -180,20 +182,23 @@ func (p *Proxy) getRoute(service string) ([]string, error) {
|
|||||||
// TODO: implement backoff and retries
|
// TODO: implement backoff and retries
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
// call the router
|
// call the router
|
||||||
pbRoutes, err = p.RouterService.Lookup(context.Background(), &pb.LookupRequest{
|
proutes, err := p.RouterService.Lookup(context.Background(), &pb.LookupRequest{
|
||||||
Query: &pb.Query{
|
Query: &pb.Query{
|
||||||
Destination: service,
|
Destination: service,
|
||||||
},
|
},
|
||||||
}, client.WithAddress(addr))
|
}, client.WithAddress(addr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
gerr = err
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// set routes
|
||||||
|
pbRoutes = proutes
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// errored out
|
// errored out
|
||||||
if err != nil {
|
if gerr != nil {
|
||||||
return nil, err
|
return nil, gerr
|
||||||
}
|
}
|
||||||
|
|
||||||
// no routes
|
// no routes
|
||||||
@ -340,6 +345,8 @@ func NewProxy(opts ...options.Option) proxy.Proxy {
|
|||||||
r, ok := p.Options.Values().Get("proxy.router")
|
r, ok := p.Options.Values().Get("proxy.router")
|
||||||
if ok {
|
if ok {
|
||||||
p.Router = r.(router.Router)
|
p.Router = r.(router.Router)
|
||||||
|
// TODO: should we advertise?
|
||||||
|
go p.Router.Advertise()
|
||||||
}
|
}
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
Loading…
x
Reference in New Issue
Block a user