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

@@ -20,7 +20,7 @@ require (
github.com/prometheus/client_golang v1.7.1
github.com/rs/zerolog v1.20.0
github.com/spf13/viper v1.7.1
github.com/thejerf/suture v4.0.0+incompatible
github.com/thejerf/suture/v4 v4.0.0
go.opencensus.io v0.23.0
)

View File

@@ -1550,6 +1550,8 @@ github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
github.com/thejerf/suture v4.0.0+incompatible h1:luAwgEo87y1X30wEYa64N4SKMrsAm9qXRwNxnLVuuwg=
github.com/thejerf/suture v4.0.0+incompatible/go.mod h1:ibKwrVj+Uzf3XZdAiNWUouPaAbSoemxOHLmJmwheEMc=
github.com/thejerf/suture/v4 v4.0.0 h1:GX3X+1Qaewtj9flL2wgoTBfLA5NcmrCY39TJRpPbUrI=
github.com/thejerf/suture/v4 v4.0.0/go.mod h1:g0e8vwskm9tI0jRjxrnA6lSr0q6OfPdWJVX7G5bVWRs=
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=

View File

@@ -5,16 +5,15 @@ import (
"os"
"strings"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/glauth/pkg/config"
"github.com/owncloud/ocis/glauth/pkg/flagset"
"github.com/owncloud/ocis/glauth/pkg/version"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/spf13/viper"
"github.com/thejerf/suture"
"github.com/thejerf/suture/v4"
)
// Execute is the entry point for the ocis-glauth command.
@@ -115,31 +114,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
// SutureService allows for the glauth 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 glauth.SutureService
func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service {
sctx, cancel := context.WithCancel(ctx)
cfg.GLAuth.Context = sctx
func NewSutureService(cfg *ociscfg.Config) suture.Service {
if cfg.Mode == 0 {
cfg.GLAuth.Supervised = true
}
return SutureService{
ctx: sctx,
cancel: cancel,
cfg: cfg.GLAuth,
cfg: cfg.GLAuth,
}
}
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
}