From d85ca7abd23d9d22cbd14b35ce4affd25db47286 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Fri, 27 Sep 2019 14:29:00 +0100 Subject: [PATCH] Set registry TTL properly via protobuf Options --- registry/service/service.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/registry/service/service.go b/registry/service/service.go index 9585c242..5bc3cffb 100644 --- a/registry/service/service.go +++ b/registry/service/service.go @@ -58,13 +58,12 @@ 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) - } + // encode srv into protobuf and pack Register TTL into it + pbSrv := ToProto(srv) + pbSrv.Options.Ttl = int64(options.TTL.Seconds()) // register the service - _, err := s.client.Register(ctx, ToProto(srv), s.callOpts()...) + _, err := s.client.Register(context.TODO(), pbSrv, s.callOpts()...) if err != nil { return err }