From fd88b899957d45f7f7bd70554876c8afb265b408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 22 Jul 2024 11:05:34 +0200 Subject: [PATCH] fix micro ocdav service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .../unreleased/fix-micro-ocdav-registry.md | 6 ++++++ pkg/micro/ocdav/option.go | 18 ++++++++++++++++++ pkg/micro/ocdav/service.go | 5 ++--- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/fix-micro-ocdav-registry.md diff --git a/changelog/unreleased/fix-micro-ocdav-registry.md b/changelog/unreleased/fix-micro-ocdav-registry.md new file mode 100644 index 0000000000..460f2284af --- /dev/null +++ b/changelog/unreleased/fix-micro-ocdav-registry.md @@ -0,0 +1,6 @@ +Bugfix: Fix micro ocdav service init and registration + +We no longer call Init to configure default options because it was replacing the existing options. + +https://github.com/cs3org/reva/pull/4843 +https://github.com/cs3org/reva/pull/4774 diff --git a/pkg/micro/ocdav/option.go b/pkg/micro/ocdav/option.go index 9d7ebdabe4..099b592242 100644 --- a/pkg/micro/ocdav/option.go +++ b/pkg/micro/ocdav/option.go @@ -21,6 +21,7 @@ package ocdav import ( "context" "crypto/tls" + "time" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav" @@ -70,6 +71,9 @@ type Options struct { AllowedHeaders []string AllowedMethods []string AllowDepthInfinity bool + + RegisterTTL time.Duration + RegisterInterval time.Duration } // newOptions initializes the available default options. @@ -383,3 +387,17 @@ func ItemNameMaxLength(i int) Option { o.config.NameValidation.MaxLength = i } } + +// RegisterTTL provides a function to set the RegisterTTL option. +func RegisterTTL(ttl time.Duration) Option { + return func(o *Options) { + o.RegisterTTL = ttl + } +} + +// RegisterInterval provides a function to set the RegisterInterval option. +func RegisterInterval(interval time.Duration) Option { + return func(o *Options) { + o.RegisterInterval = interval + } +} diff --git a/pkg/micro/ocdav/service.go b/pkg/micro/ocdav/service.go index 252288d544..fb0aed30c3 100644 --- a/pkg/micro/ocdav/service.go +++ b/pkg/micro/ocdav/service.go @@ -78,6 +78,8 @@ func Service(opts ...Option) (micro.Service, error) { server.Name(sopts.Name), server.Address(sopts.Address), // Address defaults to ":0" and will pick any free port server.Version(sopts.config.VersionString), + server.RegisterTTL(sopts.RegisterTTL), + server.RegisterInterval(sopts.RegisterInterval), ) revaService, err := ocdav.NewWith(&sopts.config, sopts.FavoriteManager, sopts.lockSystem, &sopts.Logger, sopts.GatewaySelector) @@ -125,9 +127,6 @@ func Service(opts ...Option) (micro.Service, error) { micro.Registry(registry.GetRegistry()), ) - // Init the service? make that optional? - service.Init() - // finally, return the service so it can be Run() by the caller himself return service, nil }