fix(collaboration): re register app providers in a configurable interval

This commit is contained in:
Florian Schade
2025-06-10 16:53:52 +02:00
parent 9a2dd317b2
commit e226efa4fb
3 changed files with 24 additions and 10 deletions

View File

@@ -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),

View File

@@ -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

View File

@@ -65,6 +65,7 @@ func DefaultConfig() *config.Config {
DataGateway: config.DataGateway{
Insecure: false,
},
APPRegistrationInterval: 30 * time.Second,
},
}
}