diff --git a/changelog/unreleased/fix-micro-ocdav-registry.md b/changelog/unreleased/fix-micro-ocdav-registry.md new file mode 100644 index 0000000000..7fd834a56f --- /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/4842 +https://github.com/cs3org/reva/pull/4774 diff --git a/go.mod b/go.mod index 7a465ac5e5..b753ce19e3 100644 --- a/go.mod +++ b/go.mod @@ -227,7 +227,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348 +replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90 replace github.com/studio-b12/gowebdav => github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6 diff --git a/go.sum b/go.sum index 18ee449008..f7edd7a4c1 100644 --- a/go.sum +++ b/go.sum @@ -1324,8 +1324,8 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348 h1:Czv6AW9Suj6npWd5BLZjobdD78c2RdzBeKBgkq3jYZk= -github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348/go.mod h1:Goi4eJ9SrKkxE6NsAVqBVNxfQFbwb7UbyII6743ldgM= +github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90 h1:pfI8Z5yavO6fU6vDGlWhZ4BgDlvj8c6xB7J57HfTPwA= +github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= diff --git a/pkg/micro/ocdav/option.go b/pkg/micro/ocdav/option.go index 9d7ebdabe4..6e9693bf57 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" @@ -29,6 +30,7 @@ import ( "github.com/cs3org/reva/v2/pkg/storage/favorite" "github.com/rs/zerolog" "go-micro.dev/v4/broker" + "go-micro.dev/v4/registry" "go.opentelemetry.io/otel/trace" "google.golang.org/grpc/credentials" ) @@ -70,6 +72,10 @@ type Options struct { AllowedHeaders []string AllowedMethods []string AllowDepthInfinity bool + + RegisterTTL time.Duration + RegisterInterval time.Duration + Registry registry.Registry } // newOptions initializes the available default options. @@ -383,3 +389,24 @@ 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 + } +} + +// Registry provides a function to set the Registry option. +func Registry(registry registry.Registry) Option { + return func(o *Options) { + o.Registry = registry + } +} diff --git a/pkg/micro/ocdav/service.go b/pkg/micro/ocdav/service.go index 252288d544..d9eb73fbfc 100644 --- a/pkg/micro/ocdav/service.go +++ b/pkg/micro/ocdav/service.go @@ -78,6 +78,9 @@ 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), + server.Registry(sopts.Registry), ) revaService, err := ocdav.NewWith(&sopts.config, sopts.FavoriteManager, sopts.lockSystem, &sopts.Logger, sopts.GatewaySelector) @@ -125,9 +128,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 }