Added Registry TTL to memory registry. Tracking node lifetimes.

This commit is contained in:
Milos Gajdos
2019-09-25 16:20:42 +01:00
parent 219d759f1d
commit 16c7b3a390
3 changed files with 114 additions and 17 deletions

View File

@@ -58,8 +58,13 @@ func (s *serviceRegistry) Register(srv *registry.Service, opts ...registry.Regis
o(&options)
}
ctx := context.Background()
if options.TTL.Nanoseconds() != 0.0 {
ctx = context.WithValue(ctx, "register_ttl", options.TTL)
}
// register the service
_, err := s.client.Register(context.TODO(), ToProto(srv), s.callOpts()...)
_, err := s.client.Register(ctx, ToProto(srv), s.callOpts()...)
if err != nil {
return err
}