mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
correctly implement suture v4 interfaces
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/owncloud/ocis/store/pkg/flagset"
|
||||
"github.com/owncloud/ocis/store/pkg/version"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// Execute is the entry point for the ocis-store command.
|
||||
@@ -116,31 +116,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
|
||||
// SutureService allows for the store command to be embedded and supervised by a suture supervisor tree.
|
||||
type SutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewSutureService creates a new store.SutureService
|
||||
func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Store.Context = sctx
|
||||
func NewSutureService(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Store.Supervised = true
|
||||
}
|
||||
return SutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Store,
|
||||
cfg: cfg.Store,
|
||||
}
|
||||
}
|
||||
|
||||
func (s SutureService) Serve() {
|
||||
func (s SutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Context = ctx
|
||||
if err := Execute(s.cfg); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s SutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user