mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
Set registry TTL properly via protobuf Options
This commit is contained in:
parent
e973bfaa25
commit
d85ca7abd2
@ -58,13 +58,12 @@ func (s *serviceRegistry) Register(srv *registry.Service, opts ...registry.Regis
|
|||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
// encode srv into protobuf and pack Register TTL into it
|
||||||
if options.TTL.Nanoseconds() != 0.0 {
|
pbSrv := ToProto(srv)
|
||||||
ctx = context.WithValue(ctx, "register_ttl", options.TTL)
|
pbSrv.Options.Ttl = int64(options.TTL.Seconds())
|
||||||
}
|
|
||||||
|
|
||||||
// register the service
|
// register the service
|
||||||
_, err := s.client.Register(ctx, ToProto(srv), s.callOpts()...)
|
_, err := s.client.Register(context.TODO(), pbSrv, s.callOpts()...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user