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
+14 -6
View File
@@ -4,10 +4,14 @@ import (
"context" "context"
"fmt" "fmt"
"net" "net"
"time"
"github.com/oklog/run" "github.com/oklog/run"
"github.com/urfave/cli/v2"
microstore "go-micro.dev/v4/store"
"github.com/opencloud-eu/opencloud/pkg/config/configlog" "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/pkg/tracing"
"github.com/opencloud-eu/opencloud/services/collaboration/pkg/config" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/config"
"github.com/opencloud-eu/opencloud/services/collaboration/pkg/config/parser" "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/opencloud/services/collaboration/pkg/server/http"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool" "github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
"github.com/opencloud-eu/reva/v2/pkg/store" "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. // Server is the entrypoint for the server command.
@@ -68,9 +70,15 @@ func Server(cfg *config.Config) *cli.Command {
return err return err
} }
if err := helpers.RegisterAppProvider(ctx, cfg, logger, gatewaySelector, appUrls); err != nil { ticker := time.NewTicker(cfg.CS3Api.APPRegistrationInterval)
return err 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( st := store.Create(
store.Store(cfg.Store.Store), store.Store(cfg.Store.Store),
+9 -4
View File
@@ -1,12 +1,17 @@
package config 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. // CS3Api defines the available configuration in order to access to the CS3 gateway.
type CS3Api struct { type CS3Api struct {
Gateway Gateway `yaml:"gateway"` Gateway Gateway `yaml:"gateway"`
DataGateway DataGateway `yaml:"datagateway"` DataGateway DataGateway `yaml:"datagateway"`
GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` 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 // Gateway defines the available configuration for the CS3 API gateway
@@ -65,6 +65,7 @@ func DefaultConfig() *config.Config {
DataGateway: config.DataGateway{ DataGateway: config.DataGateway{
Insecure: false, Insecure: false,
}, },
APPRegistrationInterval: 30 * time.Second,
}, },
} }
} }