Skip to content

Commit

Permalink
fix micro ocdav service
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Sep 10, 2024
1 parent 0e84ed8 commit fd88b89
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-micro-ocdav-registry.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions pkg/micro/ocdav/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
}
5 changes: 2 additions & 3 deletions pkg/micro/ocdav/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit fd88b89

Please sign in to comment.