diff --git a/services/collaboration/pkg/command/server.go b/services/collaboration/pkg/command/server.go index 9096da15a0..a048470b6b 100644 --- a/services/collaboration/pkg/command/server.go +++ b/services/collaboration/pkg/command/server.go @@ -4,10 +4,14 @@ import ( "context" "fmt" "net" + "time" "github.com/oklog/run" + "github.com/urfave/cli/v2" + microstore "go-micro.dev/v4/store" + "github.com/opencloud-eu/opencloud/pkg/config/configlog" - registry "github.com/opencloud-eu/opencloud/pkg/registry" + "github.com/opencloud-eu/opencloud/pkg/registry" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/config" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/config/parser" @@ -19,8 +23,6 @@ import ( "github.com/opencloud-eu/opencloud/services/collaboration/pkg/server/http" "github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool" "github.com/opencloud-eu/reva/v2/pkg/store" - "github.com/urfave/cli/v2" - microstore "go-micro.dev/v4/store" ) // Server is the entrypoint for the server command. @@ -68,9 +70,15 @@ func Server(cfg *config.Config) *cli.Command { return err } - if err := helpers.RegisterAppProvider(ctx, cfg, logger, gatewaySelector, appUrls); err != nil { - return err - } + ticker := time.NewTicker(cfg.CS3Api.APPRegistrationInterval) + defer ticker.Stop() + go func() { + for ; true; <-ticker.C { + if err := helpers.RegisterAppProvider(ctx, cfg, logger, gatewaySelector, appUrls); err != nil { + logger.Warn().Err(err).Msg("Failed to register app provider") + } + } + }() st := store.Create( store.Store(cfg.Store.Store), diff --git a/services/collaboration/pkg/config/cs3api.go b/services/collaboration/pkg/config/cs3api.go index cb91b43ef1..bc83632264 100644 --- a/services/collaboration/pkg/config/cs3api.go +++ b/services/collaboration/pkg/config/cs3api.go @@ -1,12 +1,17 @@ package config -import "github.com/opencloud-eu/opencloud/pkg/shared" +import ( + "time" + + "github.com/opencloud-eu/opencloud/pkg/shared" +) // CS3Api defines the available configuration in order to access to the CS3 gateway. type CS3Api struct { - Gateway Gateway `yaml:"gateway"` - DataGateway DataGateway `yaml:"datagateway"` - GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` + Gateway Gateway `yaml:"gateway"` + DataGateway DataGateway `yaml:"datagateway"` + GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` + APPRegistrationInterval time.Duration `yaml:"app_registration_interval" env:"COLLABORATION_CS3API_APP_REGISTRATION_INTERVAL" desc:"The interval at which the app provider registers itself." introductionVersion:"%%NEXT%%"` } // Gateway defines the available configuration for the CS3 API gateway diff --git a/services/collaboration/pkg/config/defaults/defaultconfig.go b/services/collaboration/pkg/config/defaults/defaultconfig.go index 215e11a80d..a25a96d6cd 100644 --- a/services/collaboration/pkg/config/defaults/defaultconfig.go +++ b/services/collaboration/pkg/config/defaults/defaultconfig.go @@ -65,6 +65,7 @@ func DefaultConfig() *config.Config { DataGateway: config.DataGateway{ Insecure: false, }, + APPRegistrationInterval: 30 * time.Second, }, } }