Use lazy initialization for the default grpc client

This avoids using a public global variable. It allows us to initialize
the default client a bit later (outside of init()). That way we can e.g.
properly initialize the in-memory registry.
This commit is contained in:
Ralf Haferkamp
2022-09-26 16:25:56 +02:00
committed by Ralf Haferkamp
parent 0ae75f8e66
commit 01650a5023
7 changed files with 28 additions and 18 deletions
+2 -2
View File
@@ -127,7 +127,7 @@ func Server(cfg *config.Config) *cli.Command {
}
func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config) alice.Chain {
rolesClient := settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
rolesClient := settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient())
revaClient, err := cs3.GetGatewayServiceClient(cfg.Reva.Address)
var userProvider backend.UserBackend
switch cfg.AccountBackend {
@@ -145,7 +145,7 @@ func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config)
logger.Fatal().Msgf("Invalid accounts backend type '%s'", cfg.AccountBackend)
}
storeClient := storesvc.NewStoreService("com.owncloud.api.store", grpc.DefaultClient)
storeClient := storesvc.NewStoreService("com.owncloud.api.store", grpc.DefaultClient())
if err != nil {
logger.Error().Err(err).
Str("gateway", cfg.Reva.Address).