Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix micro ocdav service #4774

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelog/unreleased/bump-ocis.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Change: Ocis bumped.
Change: Ocis bumped

Ocis bumped. The expected failures removed.

Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-micro-ocdav-registry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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/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
Loading