Skip to content

Commit

Permalink
Use ocis registry for refresh
Browse files Browse the repository at this point in the history
The go-micro registry-singleton ignores the ocis configuration and defaults to mdns
  • Loading branch information
IljaN committed Jun 7, 2021
1 parent 8ec6ac3 commit 073503b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-use-configured-registry
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: External storage registration used wrong config

The go-micro registry-singleton ignores the ocis configuration and defaults to mdns

https://github.com/owncloud/ocis/pull/2120
10 changes: 5 additions & 5 deletions storage/pkg/service/external/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func RegisterGRPCEndpoint(ctx context.Context, serviceID, uuid, addr string, log
Address: addr,
Metadata: make(map[string]string),
}
r := oregistry.GetRegistry()
ocisRegistry := oregistry.GetRegistry()

node.Metadata["broker"] = broker.String()
node.Metadata["registry"] = r.String()
node.Metadata["registry"] = ocisRegistry.String()
node.Metadata["server"] = "grpc"
node.Metadata["transport"] = "grpc"
node.Metadata["protocol"] = "grpc"
Expand All @@ -37,7 +37,7 @@ func RegisterGRPCEndpoint(ctx context.Context, serviceID, uuid, addr string, log
logger.Info().Msgf("registering external service %v@%v", node.Id, node.Address)

rOpts := []registry.RegisterOption{registry.RegisterTTL(time.Minute)}
if err := r.Register(service, rOpts...); err != nil {
if err := ocisRegistry.Register(service, rOpts...); err != nil {
logger.Fatal().Err(err).Msgf("Registration error for external service %v", serviceID)
}

Expand All @@ -48,14 +48,14 @@ func RegisterGRPCEndpoint(ctx context.Context, serviceID, uuid, addr string, log
select {
case <-t.C:
logger.Debug().Interface("service", service).Msg("refreshing external service-registration")
err := registry.Register(service, rOpts...)
err := ocisRegistry.Register(service, rOpts...)
if err != nil {
logger.Error().Err(err).Msgf("registration error for external service %v", serviceID)
}
case <-ctx.Done():
logger.Debug().Interface("service", service).Msg("unregistering")
t.Stop()
err := registry.Deregister(service)
err := ocisRegistry.Deregister(service)
if err != nil {
logger.Err(err).Msgf("Error unregistering external service %v", serviceID)
}
Expand Down

0 comments on commit 073503b

Please sign in to comment.