correctly implement suture v4 interfaces

This commit is contained in:
A.Unger
2021-03-11 15:50:01 +01:00
parent 99ad1cdd25
commit dc4b4b7e46
53 changed files with 322 additions and 448 deletions

View File

@@ -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
}