From 393577e5e69c9bcc5564b5a40a7a1c61445e5fce Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 9 Aug 2020 16:17:52 +0100 Subject: [PATCH] add a noop registry --- grpc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/grpc.go b/grpc.go index 6dadbfd..0ce2a48 100644 --- a/grpc.go +++ b/grpc.go @@ -595,6 +595,11 @@ func (g *grpcServer) Register() error { config := g.opts g.RUnlock() + // only register if it exists or is not noop + if config.Registry == nil || config.Registry.String() == "noop" { + return nil + } + regFunc := func(service *registry.Service) error { var regErr error @@ -779,6 +784,11 @@ func (g *grpcServer) Deregister() error { config := g.opts g.RUnlock() + // only register if it exists or is not noop + if config.Registry == nil || config.Registry.String() == "noop" { + return nil + } + // check the advertise address first // if it exists then use it, otherwise // use the address