From dc4b4b7e46ba2bd36545985eed431631a92ed597 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 11 Mar 2021 15:50:01 +0100 Subject: [PATCH] correctly implement suture v4 interfaces --- accounts/go.mod | 1 + accounts/go.sum | 2 + accounts/pkg/command/root.go | 23 ++++------ glauth/go.mod | 2 +- glauth/go.sum | 2 + glauth/pkg/command/root.go | 26 ++++------- graph-explorer/go.sum | 1 + graph/go.sum | 1 + idp/go.mod | 6 +-- idp/go.sum | 13 +++--- idp/pkg/command/root.go | 26 ++++------- ocis-pkg/go.mod | 1 + ocis-pkg/go.sum | 3 ++ ocis/go.mod | 1 + ocis/go.sum | 4 ++ ocis/pkg/runtime/service/service.go | 56 ++++++++++++------------ ocs/go.mod | 1 + ocs/go.sum | 2 + ocs/pkg/command/root.go | 23 ++++------ onlyoffice/go.mod | 2 +- onlyoffice/go.sum | 3 ++ onlyoffice/pkg/command/root.go | 23 ++++------ proxy/go.mod | 1 + proxy/go.sum | 2 + proxy/pkg/command/root.go | 23 ++++------ settings/go.mod | 1 + settings/go.sum | 2 + settings/pkg/command/root.go | 23 ++++------ storage/go.mod | 1 + storage/go.sum | 3 ++ storage/pkg/command/authbasic.go | 33 ++++++-------- storage/pkg/command/authbearer.go | 33 ++++++-------- storage/pkg/command/frontend.go | 33 ++++++-------- storage/pkg/command/gateway.go | 33 ++++++-------- storage/pkg/command/groups.go | 33 ++++++-------- storage/pkg/command/sharing.go | 33 ++++++-------- storage/pkg/command/storagehome.go | 33 ++++++-------- storage/pkg/command/storagemetadata.go | 33 ++++++-------- storage/pkg/command/storagepubliclink.go | 33 ++++++-------- storage/pkg/command/storageusers.go | 33 ++++++-------- storage/pkg/command/users.go | 33 ++++++-------- store/go.mod | 13 +----- store/go.sum | 11 +++-- store/pkg/command/root.go | 23 ++++------ thumbnails/go.mod | 1 + thumbnails/go.sum | 3 ++ thumbnails/pkg/command/root.go | 23 ++++------ web/go.mod | 1 + web/go.sum | 2 + web/pkg/command/root.go | 23 ++++------ webdav/go.mod | 2 +- webdav/go.sum | 4 ++ webdav/pkg/command/root.go | 23 ++++------ 53 files changed, 322 insertions(+), 448 deletions(-) diff --git a/accounts/go.mod b/accounts/go.mod index 4bfe0901d..d693278a7 100644 --- a/accounts/go.mod +++ b/accounts/go.mod @@ -29,6 +29,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/net v0.0.0-20210119194325-5f4716e94777 diff --git a/accounts/go.sum b/accounts/go.sum index bfeb5629f..85764a9f1 100644 --- a/accounts/go.sum +++ b/accounts/go.sum @@ -1547,6 +1547,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= diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index d4ded0213..0dc270fc9 100644 --- a/accounts/pkg/command/root.go +++ b/accounts/pkg/command/root.go @@ -15,7 +15,7 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) var ( @@ -127,31 +127,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the accounts 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 accounts.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Accounts.Context = sctx // propagate the context down to the go-micro services. +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Accounts.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Accounts, + cfg: cfg.Accounts, } } -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 } diff --git a/glauth/go.mod b/glauth/go.mod index 33f9ec4dd..8248a0d0f 100644 --- a/glauth/go.mod +++ b/glauth/go.mod @@ -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 ) diff --git a/glauth/go.sum b/glauth/go.sum index 4b16f0985..fff97592b 100644 --- a/glauth/go.sum +++ b/glauth/go.sum @@ -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= diff --git a/glauth/pkg/command/root.go b/glauth/pkg/command/root.go index ec12f0adc..7db6ee288 100644 --- a/glauth/pkg/command/root.go +++ b/glauth/pkg/command/root.go @@ -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 } diff --git a/graph-explorer/go.sum b/graph-explorer/go.sum index 9032c651f..da8fc2492 100644 --- a/graph-explorer/go.sum +++ b/graph-explorer/go.sum @@ -1450,6 +1450,7 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= +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= diff --git a/graph/go.sum b/graph/go.sum index 88a8e3245..4fd371ad0 100644 --- a/graph/go.sum +++ b/graph/go.sum @@ -1452,6 +1452,7 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= +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= diff --git a/idp/go.mod b/idp/go.mod index fea8ab0f4..9c035dcc5 100644 --- a/idp/go.mod +++ b/idp/go.mod @@ -9,21 +9,17 @@ require ( github.com/asim/go-micro/v3 v3.5.1-0.20210217182006-0f0ace1a44a9 github.com/go-chi/chi v4.1.2+incompatible github.com/gorilla/mux v1.8.0 - github.com/gorilla/schema v1.2.0 // indirect - github.com/imdario/mergo v0.3.11 // indirect github.com/micro/cli/v2 v2.1.2 github.com/oklog/run v1.1.0 github.com/olekukonko/tablewriter v0.0.4 github.com/openzipkin/zipkin-go v0.2.5 github.com/owncloud/ocis/ocis-pkg v0.0.0-20210216094451-dc73176dc62d - github.com/pquerna/cachecontrol v0.0.0-20200921180117-858c6e7e6b7e // indirect github.com/prometheus/client_golang v1.7.1 github.com/rs/zerolog v1.20.0 github.com/sirupsen/logrus v1.7.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 - golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect golang.org/x/mod v0.4.1 // indirect golang.org/x/net v0.0.0-20201224014010-6772e930b67b stash.kopano.io/kc/konnect v0.33.3 diff --git a/idp/go.sum b/idp/go.sum index b39622797..884e33824 100644 --- a/idp/go.sum +++ b/idp/go.sum @@ -715,6 +715,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-jsonnet v0.16.0/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw= @@ -747,6 +748,7 @@ github.com/gopherjs/gopherjs v0.0.0-20181004151105-1babbf986f6f/go.mod h1:wJfORR github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= @@ -1482,9 +1484,10 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= -github.com/thejerf/suture v1.1.1 h1:Wg9YwKMlCIAa9XbEeFyrYDGF9OXq0f6hDl4bdy+mVdE= 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= @@ -1648,6 +1651,7 @@ golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c h1:9HhBz5L/UjnK9XLtiZhYAdue5BVKep3PMmS2LuPDt8k= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= @@ -1873,7 +1877,6 @@ golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b h1:lAZ0/chPUDWwjqosYR0X4M490zQhMsiJ4K3DbA7o+3g= golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -1984,9 +1987,8 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200811215021-48a8ffc5b207/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064 h1:BmCFkEH4nJrYcAc2L08yX5RhYGD4j58PTMkEUDkpz2I= golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2167,9 +2169,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k= honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.1.1 h1:EVDuO03OCZwpV2t/tLLxPmPiomagMoBOgfPt0FM+4IY= -honnef.co/go/tools v0.1.1/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= diff --git a/idp/pkg/command/root.go b/idp/pkg/command/root.go index 3cddab916..3f8c37535 100644 --- a/idp/pkg/command/root.go +++ b/idp/pkg/command/root.go @@ -5,16 +5,15 @@ import ( "os" "strings" - "github.com/owncloud/ocis/ocis-pkg/sync" - "github.com/micro/cli/v2" "github.com/owncloud/ocis/idp/pkg/config" "github.com/owncloud/ocis/idp/pkg/flagset" "github.com/owncloud/ocis/idp/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-idp command. @@ -116,31 +115,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the idp 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 idp.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.IDP.Context = sctx +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.IDP.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.IDP, + cfg: cfg.IDP, } } -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 } diff --git a/ocis-pkg/go.mod b/ocis-pkg/go.mod index 04f2e0eba..d6ebbdde2 100644 --- a/ocis-pkg/go.mod +++ b/ocis-pkg/go.mod @@ -23,6 +23,7 @@ require ( github.com/iancoleman/strcase v0.1.2 github.com/justinas/alice v1.2.0 github.com/micro/cli/v2 v2.1.2 + github.com/oklog/run v1.1.0 github.com/owncloud/ocis/accounts v0.5.3-0.20210216094451-dc73176dc62d github.com/owncloud/ocis/glauth v0.0.0-20210216094451-dc73176dc62d github.com/owncloud/ocis/graph v0.0.0-20210216094451-dc73176dc62d diff --git a/ocis-pkg/go.sum b/ocis-pkg/go.sum index cb40cc89f..c759e75bf 100644 --- a/ocis-pkg/go.sum +++ b/ocis-pkg/go.sum @@ -753,6 +753,7 @@ github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY= +github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY= github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= @@ -1437,6 +1438,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= diff --git a/ocis/go.mod b/ocis/go.mod index bad1c6426..084b50ddd 100644 --- a/ocis/go.mod +++ b/ocis/go.mod @@ -34,6 +34,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b ) diff --git a/ocis/go.sum b/ocis/go.sum index b50dff0d9..906e49b31 100644 --- a/ocis/go.sum +++ b/ocis/go.sum @@ -771,6 +771,7 @@ github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY= +github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY= github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= @@ -1228,6 +1229,7 @@ github.com/pkg/xattr v0.4.3/go.mod h1:sBD3RAqlr8Q+RC3FutZcikpT8nyDrIEEBw2J744gVW github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 h1:J9b7z+QKAmPf4YLrFg6oQUotqHQeUNWwkvo7jZp1GLU= github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/pquerna/cachecontrol v0.0.0-20200921180117-858c6e7e6b7e h1:BLqxdwZ6j771IpSCRx7s/GJjXHUE00Hmu7/YegCGdzA= github.com/pquerna/cachecontrol v0.0.0-20200921180117-858c6e7e6b7e/go.mod h1:hoLfEwdY11HjRfKFH6KqnPsfxlo3BP6bJehpDv8t6sQ= @@ -1455,6 +1457,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= diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index d15c23937..a1d089b3a 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -13,36 +13,33 @@ import ( "syscall" "time" - "github.com/mohae/deepcopy" - mzlog "github.com/asim/go-micro/plugins/logger/zerolog/v3" - accounts "github.com/owncloud/ocis/accounts/pkg/command" - ocs "github.com/owncloud/ocis/ocs/pkg/command" - onlyoffice "github.com/owncloud/ocis/onlyoffice/pkg/command" - proxy "github.com/owncloud/ocis/proxy/pkg/command" - store "github.com/owncloud/ocis/store/pkg/command" - thumbnails "github.com/owncloud/ocis/thumbnails/pkg/command" - web "github.com/owncloud/ocis/web/pkg/command" - webdav "github.com/owncloud/ocis/webdav/pkg/command" - "github.com/asim/go-micro/v3/logger" - "github.com/thejerf/suture" - + "github.com/mohae/deepcopy" "github.com/olekukonko/tablewriter" + accounts "github.com/owncloud/ocis/accounts/pkg/command" glauth "github.com/owncloud/ocis/glauth/pkg/command" idp "github.com/owncloud/ocis/idp/pkg/command" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" + ocs "github.com/owncloud/ocis/ocs/pkg/command" + onlyoffice "github.com/owncloud/ocis/onlyoffice/pkg/command" + proxy "github.com/owncloud/ocis/proxy/pkg/command" settings "github.com/owncloud/ocis/settings/pkg/command" storage "github.com/owncloud/ocis/storage/pkg/command" + store "github.com/owncloud/ocis/store/pkg/command" + thumbnails "github.com/owncloud/ocis/thumbnails/pkg/command" + web "github.com/owncloud/ocis/web/pkg/command" + webdav "github.com/owncloud/ocis/webdav/pkg/command" "github.com/rs/zerolog" + "github.com/thejerf/suture/v4" ) // Service represents a RPC service. type Service struct { Supervisor *suture.Supervisor - ServicesRegistry map[string]func(context.Context, *ociscfg.Config) suture.Service - Delayed map[string]func(context.Context, *ociscfg.Config) suture.Service + ServicesRegistry map[string]func(*ociscfg.Config) suture.Service + Delayed map[string]func(*ociscfg.Config) suture.Service Log log.Logger serviceToken map[string][]suture.ServiceToken @@ -72,8 +69,8 @@ func NewService(options ...Option) (*Service, error) { globalCtx, cancelGlobal := context.WithCancel(context.Background()) s := &Service{ - ServicesRegistry: make(map[string]func(context.Context, *ociscfg.Config) suture.Service), - Delayed: make(map[string]func(context.Context, *ociscfg.Config) suture.Service), + ServicesRegistry: make(map[string]func(*ociscfg.Config) suture.Service), + Delayed: make(map[string]func(*ociscfg.Config) suture.Service), Log: l, serviceToken: make(map[string][]suture.ServiceToken), @@ -88,7 +85,6 @@ func NewService(options ...Option) (*Service, error) { s.ServicesRegistry["idp"] = idp.NewSutureService s.ServicesRegistry["ocs"] = ocs.NewSutureService s.ServicesRegistry["onlyoffice"] = onlyoffice.NewSutureService - //s.ServicesRegistry["proxy"] = proxy.NewSutureService s.ServicesRegistry["store"] = store.NewSutureService s.ServicesRegistry["thumbnails"] = thumbnails.NewSutureService s.ServicesRegistry["web"] = web.NewSutureService @@ -124,8 +120,8 @@ func Start(o ...Option) error { // Start creates its own supervisor. Running services under `ocis server` will create its own supervision tree. s.Supervisor = suture.New("ocis", suture.Spec{ - Log: func(msg string) { - s.Log.Info().Str("message", msg).Msg("supervisor: ") + EventHook: func(e suture.Event) { + s.Log.Info().Str("event", e.String()).Msg(fmt.Sprintf("supervisor: %v", e.Map()["supervisor_name"])) }, }) @@ -168,19 +164,25 @@ func Start(o ...Option) error { for name := range s.ServicesRegistry { swap := deepcopy.Copy(s.cfg) - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, swap.(*ociscfg.Config)))) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](swap.(*ociscfg.Config)))) } - go s.Supervisor.ServeBackground() + // there are reasons not to do this, but we have race conditions ourselves. Until we resolve them, mind the following disclaimer: + // Calling ServeBackground will CORRECTLY start the supervisor running in a new goroutine. It is risky to directly run + // go supervisor.Serve() + // because that will briefly create a race condition as it starts up, if you try to .Add() services immediately afterward. + // https://pkg.go.dev/github.com/thejerf/suture/v4@v4.0.0#Supervisor + go s.Supervisor.ServeBackground(s.context) // trap will block on halt channel for interruptions. go trap(s, halt) - time.Sleep(2 * time.Second) - // add delayed + time.Sleep(1 * time.Second) + + // add services with delayed execution. for name := range s.Delayed { swap := deepcopy.Copy(s.cfg) - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](s.context, swap.(*ociscfg.Config)))) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](swap.(*ociscfg.Config)))) } return http.Serve(l, nil) @@ -191,13 +193,13 @@ func (s *Service) Start(name string, reply *int) error { swap := deepcopy.Copy(s.cfg) if _, ok := s.ServicesRegistry[name]; ok { *reply = 0 - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, swap.(*ociscfg.Config)))) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](swap.(*ociscfg.Config)))) return nil } if _, ok := s.Delayed[name]; ok { *reply = 0 - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](s.context, swap.(*ociscfg.Config)))) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](swap.(*ociscfg.Config)))) return nil } diff --git a/ocs/go.mod b/ocs/go.mod index fe9ba39f1..dcee35178 100644 --- a/ocs/go.mod +++ b/ocs/go.mod @@ -25,6 +25,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 google.golang.org/genproto v0.0.0-20210207032614-bba0dbe2a9ea google.golang.org/protobuf v1.25.0 diff --git a/ocs/go.sum b/ocs/go.sum index 2fd82fa57..5a0c65c4e 100644 --- a/ocs/go.sum +++ b/ocs/go.sum @@ -1542,6 +1542,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= diff --git a/ocs/pkg/command/root.go b/ocs/pkg/command/root.go index 7fd3e87e6..2bd1945b5 100644 --- a/ocs/pkg/command/root.go +++ b/ocs/pkg/command/root.go @@ -13,7 +13,7 @@ import ( "github.com/owncloud/ocis/ocs/pkg/config" "github.com/owncloud/ocis/ocs/pkg/version" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Execute is the entry point for the ocis-ocs command. @@ -113,31 +113,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the ocs 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 ocs.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.OCS.Context = sctx +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.OCS.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.OCS, + cfg: cfg.OCS, } } -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 } diff --git a/onlyoffice/go.mod b/onlyoffice/go.mod index 042525d4a..158b51f42 100644 --- a/onlyoffice/go.mod +++ b/onlyoffice/go.mod @@ -13,7 +13,7 @@ require ( github.com/openzipkin/zipkin-go v0.2.5 github.com/owncloud/ocis/ocis-pkg v0.0.0-20210216094451-dc73176dc62d 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 golang.org/x/mod v0.4.1 // indirect golang.org/x/net v0.0.0-20201224014010-6772e930b67b diff --git a/onlyoffice/go.sum b/onlyoffice/go.sum index a2d77911d..c049d5b18 100644 --- a/onlyoffice/go.sum +++ b/onlyoffice/go.sum @@ -1485,6 +1485,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= @@ -1648,6 +1650,7 @@ golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c h1:9HhBz5L/UjnK9XLtiZhYAdue5BVKep3PMmS2LuPDt8k= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= diff --git a/onlyoffice/pkg/command/root.go b/onlyoffice/pkg/command/root.go index a2f9170d9..2ab484ccb 100644 --- a/onlyoffice/pkg/command/root.go +++ b/onlyoffice/pkg/command/root.go @@ -14,7 +14,7 @@ import ( "github.com/owncloud/ocis/onlyoffice/pkg/flagset" "github.com/owncloud/ocis/onlyoffice/pkg/version" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Execute is the entry point for the ocis-onlyoffice command. @@ -114,31 +114,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the onlyoffice 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 onlyoffice.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Onlyoffice.Context = sctx // propagate the context down to the go-micro services. +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Onlyoffice.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Onlyoffice, + cfg: cfg.Onlyoffice, } } -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 } diff --git a/proxy/go.mod b/proxy/go.mod index 5fc65fcb9..f4df828b5 100644 --- a/proxy/go.mod +++ b/proxy/go.mod @@ -26,6 +26,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/oauth2 v0.0.0-20210201163806-010130855d6c diff --git a/proxy/go.sum b/proxy/go.sum index db248e5d3..15ecc143d 100644 --- a/proxy/go.sum +++ b/proxy/go.sum @@ -1542,6 +1542,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= diff --git a/proxy/pkg/command/root.go b/proxy/pkg/command/root.go index ba2c2fec2..2de11abaa 100644 --- a/proxy/pkg/command/root.go +++ b/proxy/pkg/command/root.go @@ -14,7 +14,7 @@ import ( "github.com/owncloud/ocis/proxy/pkg/flagset" "github.com/owncloud/ocis/proxy/pkg/version" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Execute is the entry point for the ocis-proxy command. @@ -117,31 +117,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the proxy 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 proxy.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Proxy.Context = sctx +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Proxy.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Proxy, + cfg: cfg.Proxy, } } -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 } diff --git a/settings/go.mod b/settings/go.mod index d603558b7..b958b2632 100644 --- a/settings/go.mod +++ b/settings/go.mod @@ -22,6 +22,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 golang.org/x/mod v0.4.1 // indirect golang.org/x/net v0.0.0-20201224014010-6772e930b67b diff --git a/settings/go.sum b/settings/go.sum index 357ac6e57..20756b2cf 100644 --- a/settings/go.sum +++ b/settings/go.sum @@ -1501,6 +1501,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= diff --git a/settings/pkg/command/root.go b/settings/pkg/command/root.go index d72c7a0d3..58e71cf78 100644 --- a/settings/pkg/command/root.go +++ b/settings/pkg/command/root.go @@ -14,7 +14,7 @@ import ( "github.com/owncloud/ocis/settings/pkg/flagset" "github.com/owncloud/ocis/settings/pkg/version" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Execute is the entry point for the ocis-settings command. @@ -116,31 +116,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree. type SutureService struct { - ctx context.Context - cancel context.CancelFunc - cfg *config.Config + cfg *config.Config } // NewSutureService creates a new settings.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Settings.Context = sctx +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Settings.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Settings, + cfg: cfg.Settings, } } -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 } diff --git a/storage/go.mod b/storage/go.mod index c717d6f3c..ec827d97b 100644 --- a/storage/go.mod +++ b/storage/go.mod @@ -13,6 +13,7 @@ require ( github.com/owncloud/ocis/ocis-pkg v0.0.0-20210216094451-dc73176dc62d github.com/spf13/viper v1.7.1 github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 golang.org/x/mod v0.4.1 // indirect ) diff --git a/storage/go.sum b/storage/go.sum index 46079b103..dd27de532 100644 --- a/storage/go.sum +++ b/storage/go.sum @@ -1519,6 +1519,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= @@ -1684,6 +1686,7 @@ golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c h1:9HhBz5L/UjnK9XLtiZhYAdue5BVKep3PMmS2LuPDt8k= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= diff --git a/storage/pkg/command/authbasic.go b/storage/pkg/command/authbasic.go index 0d3e96c5c..834662085 100644 --- a/storage/pkg/command/authbasic.go +++ b/storage/pkg/command/authbasic.go @@ -16,7 +16,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // AuthBasic is the entrypoint for the auth-basic command. @@ -172,43 +172,36 @@ func AuthBasic(cfg *config.Config) *cli.Command { // AuthBasicSutureService allows for the storage-authbasic command to be embedded and supervised by a suture supervisor tree. type AuthBasicSutureService 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 } // NewAuthBasicSutureService creates a new store.AuthBasicSutureService -func NewAuthBasic(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.AuthBasic.Context = sctx +func NewAuthBasic(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.AuthBasic.Supervised = true } return AuthBasicSutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s AuthBasicSutureService) Serve() { +func (s AuthBasicSutureService) Serve(ctx context.Context) error { + s.cfg.Reva.AuthBasic.Context = ctx f := &flag.FlagSet{} for k := range AuthBasic(s.cfg).Flags { if err := AuthBasic(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if AuthBasic(s.cfg).Before != nil { - if err := AuthBasic(s.cfg).Before(ctx); err != nil { - return + if err := AuthBasic(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := AuthBasic(s.cfg).Action(ctx); err != nil { - return + if err := AuthBasic(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s AuthBasicSutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/authbearer.go b/storage/pkg/command/authbearer.go index 92e87ac73..2cbf62ff4 100644 --- a/storage/pkg/command/authbearer.go +++ b/storage/pkg/command/authbearer.go @@ -15,7 +15,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // AuthBearer is the entrypoint for the auth-bearer command. @@ -152,43 +152,36 @@ func AuthBearer(cfg *config.Config) *cli.Command { // AuthBearerSutureService allows for the storage-gateway command to be embedded and supervised by a suture supervisor tree. type AuthBearerSutureService 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 } // NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService -func NewAuthBearer(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.AuthBearer.Context = sctx +func NewAuthBearer(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.AuthBearer.Supervised = true } return AuthBearerSutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s AuthBearerSutureService) Serve() { +func (s AuthBearerSutureService) Serve(ctx context.Context) error { + s.cfg.Reva.AuthBearer.Context = ctx f := &flag.FlagSet{} for k := range AuthBearer(s.cfg).Flags { if err := AuthBearer(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if AuthBearer(s.cfg).Before != nil { - if err := AuthBearer(s.cfg).Before(ctx); err != nil { - return + if err := AuthBearer(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := AuthBearer(s.cfg).Action(ctx); err != nil { - return + if err := AuthBearer(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s AuthBearerSutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index 61f4375fd..237f927d2 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -19,7 +19,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Frontend is the entrypoint for the frontend command. @@ -305,43 +305,36 @@ func loadUserAgent(c *cli.Context, cfg *config.Config) error { // FrontendSutureService allows for the storage-frontend command to be embedded and supervised by a suture supervisor tree. type FrontendSutureService 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 } // NewFrontendSutureService creates a new frontend.FrontendSutureService -func NewFrontend(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.Frontend.Context = sctx +func NewFrontend(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.Frontend.Supervised = true } return FrontendSutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s FrontendSutureService) Serve() { +func (s FrontendSutureService) Serve(ctx context.Context) error { + s.cfg.Reva.Frontend.Context = ctx f := &flag.FlagSet{} for k := range Frontend(s.cfg).Flags { if err := Frontend(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if Frontend(s.cfg).Before != nil { - if err := Frontend(s.cfg).Before(ctx); err != nil { - return + if err := Frontend(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := Frontend(s.cfg).Action(ctx); err != nil { - return + if err := Frontend(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s FrontendSutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index 59e29747a..335fc46d9 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -18,7 +18,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/service/external" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Gateway is the entrypoint for the gateway command. @@ -230,43 +230,36 @@ func rules(cfg *config.Config) map[string]interface{} { // GatewaySutureService allows for the storage-gateway command to be embedded and supervised by a suture supervisor tree. type GatewaySutureService 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 } // NewGatewaySutureService creates a new gateway.GatewaySutureService -func NewGateway(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.Gateway.Context = sctx +func NewGateway(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.Gateway.Supervised = true } return GatewaySutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s GatewaySutureService) Serve() { +func (s GatewaySutureService) Serve(ctx context.Context) error { + s.cfg.Reva.Gateway.Context = ctx f := &flag.FlagSet{} for k := range Gateway(s.cfg).Flags { if err := Gateway(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if Gateway(s.cfg).Before != nil { - if err := Gateway(s.cfg).Before(ctx); err != nil { - return + if err := Gateway(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := Gateway(s.cfg).Action(ctx); err != nil { - return + if err := Gateway(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s GatewaySutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/groups.go b/storage/pkg/command/groups.go index cbf90b9af..7707c06c9 100644 --- a/storage/pkg/command/groups.go +++ b/storage/pkg/command/groups.go @@ -17,7 +17,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Groups is the entrypoint for the sharing command. @@ -187,43 +187,36 @@ func Groups(cfg *config.Config) *cli.Command { // GroupsProvider allows for the storage-groupsprovider command to be embedded and supervised by a suture supervisor tree. type GroupsProvider 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 } // NewGroupsProvider creates a new storage.GroupsProvider -func NewGroupsProvider(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.Groups.Context = sctx +func NewGroupsProvider(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.Groups.Supervised = true } return GroupsProvider{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s GroupsProvider) Serve() { +func (s GroupsProvider) Serve(ctx context.Context) error { + s.cfg.Reva.Groups.Context = ctx f := &flag.FlagSet{} for k := range Groups(s.cfg).Flags { if err := Groups(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if Groups(s.cfg).Before != nil { - if err := Groups(s.cfg).Before(ctx); err != nil { - return + if err := Groups(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := Groups(s.cfg).Action(ctx); err != nil { - return + if err := Groups(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s GroupsProvider) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index ffd84fe58..d5f7cf556 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -17,7 +17,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Sharing is the entrypoint for the sharing command. @@ -180,43 +180,36 @@ func Sharing(cfg *config.Config) *cli.Command { // SharingSutureService allows for the storage-sharing command to be embedded and supervised by a suture supervisor tree. type SharingSutureService 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 } // NewSharingSutureService creates a new store.SharingSutureService -func NewSharing(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.Sharing.Context = sctx +func NewSharing(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.Sharing.Supervised = true } return SharingSutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s SharingSutureService) Serve() { +func (s SharingSutureService) Serve(ctx context.Context) error { + s.cfg.Reva.Sharing.Context = ctx f := &flag.FlagSet{} for k := range Sharing(s.cfg).Flags { if err := Sharing(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if Sharing(s.cfg).Before != nil { - if err := Sharing(s.cfg).Before(ctx); err != nil { - return + if err := Sharing(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := Sharing(s.cfg).Action(ctx); err != nil { - return + if err := Sharing(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s SharingSutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/storagehome.go b/storage/pkg/command/storagehome.go index 9139ed0ff..4e956c091 100644 --- a/storage/pkg/command/storagehome.go +++ b/storage/pkg/command/storagehome.go @@ -16,7 +16,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // StorageHome is the entrypoint for the storage-home command. @@ -172,43 +172,36 @@ func StorageHome(cfg *config.Config) *cli.Command { // StorageHomeSutureService allows for the storage-home command to be embedded and supervised by a suture supervisor tree. type StorageHomeSutureService 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 } // NewStorageHomeSutureService creates a new storage.StorageHomeSutureService -func NewStorageHome(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.StorageHome.Context = sctx +func NewStorageHome(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.StorageHome.Supervised = true } return StorageHomeSutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s StorageHomeSutureService) Serve() { +func (s StorageHomeSutureService) Serve(ctx context.Context) error { + s.cfg.Reva.StorageHome.Context = ctx f := &flag.FlagSet{} for k := range StorageHome(s.cfg).Flags { if err := StorageHome(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if StorageHome(s.cfg).Before != nil { - if err := StorageHome(s.cfg).Before(ctx); err != nil { - return + if err := StorageHome(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := StorageHome(s.cfg).Action(ctx); err != nil { - return + if err := StorageHome(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s StorageHomeSutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/storagemetadata.go b/storage/pkg/command/storagemetadata.go index 8013d0afe..766915557 100644 --- a/storage/pkg/command/storagemetadata.go +++ b/storage/pkg/command/storagemetadata.go @@ -17,7 +17,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/service/external" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // StorageMetadata the entrypoint for the storage-storage-metadata command. @@ -204,43 +204,36 @@ func StorageMetadata(cfg *config.Config) *cli.Command { // SutureService allows for the storage-metadata 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 storagemetadata.SutureService -func NewStorageMetadata(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.StorageMetadata.Context = sctx +func NewStorageMetadata(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.StorageMetadata.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s SutureService) Serve() { +func (s SutureService) Serve(ctx context.Context) error { + s.cfg.Reva.StorageMetadata.Context = ctx f := &flag.FlagSet{} for k := range StorageMetadata(s.cfg).Flags { if err := StorageMetadata(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if StorageMetadata(s.cfg).Before != nil { - if err := StorageMetadata(s.cfg).Before(ctx); err != nil { - return + if err := StorageMetadata(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := StorageMetadata(s.cfg).Action(ctx); err != nil { - return + if err := StorageMetadata(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s SutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/storagepubliclink.go b/storage/pkg/command/storagepubliclink.go index e476f86f7..5dbe9b965 100644 --- a/storage/pkg/command/storagepubliclink.go +++ b/storage/pkg/command/storagepubliclink.go @@ -15,7 +15,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // StoragePublicLink is the entrypoint for the reva-storage-public-link command. @@ -149,43 +149,36 @@ func StoragePublicLink(cfg *config.Config) *cli.Command { // StoragePublicLinkSutureService allows for the storage-public-link command to be embedded and supervised by a suture supervisor tree. type StoragePublicLinkSutureService 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 } // NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService -func NewStoragePublicLink(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.StoragePublicLink.Context = sctx +func NewStoragePublicLink(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.StoragePublicLink.Supervised = true } return StoragePublicLinkSutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s StoragePublicLinkSutureService) Serve() { +func (s StoragePublicLinkSutureService) Serve(ctx context.Context) error { + s.cfg.Reva.StoragePublicLink.Context = ctx f := &flag.FlagSet{} for k := range StoragePublicLink(s.cfg).Flags { if err := StoragePublicLink(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if StoragePublicLink(s.cfg).Before != nil { - if err := StoragePublicLink(s.cfg).Before(ctx); err != nil { - return + if err := StoragePublicLink(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := StoragePublicLink(s.cfg).Action(ctx); err != nil { - return + if err := StoragePublicLink(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s StoragePublicLinkSutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/storageusers.go b/storage/pkg/command/storageusers.go index 01597b604..e288fa7a9 100644 --- a/storage/pkg/command/storageusers.go +++ b/storage/pkg/command/storageusers.go @@ -15,7 +15,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // StorageUsers is the entrypoint for the storage-users command. @@ -171,43 +171,36 @@ func StorageUsers(cfg *config.Config) *cli.Command { // StorageUsersSutureService allows for the storage-home command to be embedded and supervised by a suture supervisor tree. type StorageUsersSutureService 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 } // NewStorageUsersSutureService creates a new storage.StorageUsersSutureService -func NewStorageUsers(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.StorageUsers.Context = sctx +func NewStorageUsers(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.StorageUsers.Supervised = true } return StorageUsersSutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s StorageUsersSutureService) Serve() { +func (s StorageUsersSutureService) Serve(ctx context.Context) error { + s.cfg.Reva.StorageUsers.Context = ctx f := &flag.FlagSet{} for k := range StorageUsers(s.cfg).Flags { if err := StorageUsers(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if StorageUsers(s.cfg).Before != nil { - if err := StorageUsers(s.cfg).Before(ctx); err != nil { - return + if err := StorageUsers(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := StorageUsers(s.cfg).Action(ctx); err != nil { - return + if err := StorageUsers(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s StorageUsersSutureService) Stop() { - s.cancel() + return nil } diff --git a/storage/pkg/command/users.go b/storage/pkg/command/users.go index d720bf641..d820db5a0 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -16,7 +16,7 @@ import ( "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Users is the entrypoint for the sharing command. @@ -187,43 +187,36 @@ func Users(cfg *config.Config) *cli.Command { // UsersProviderService allows for the storage-userprovider command to be embedded and supervised by a suture supervisor tree. type UsersProviderService 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 } // NewUsersProviderService creates a new storage.UsersProviderService -func NewUsersProviderService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Storage.Reva.Users.Context = sctx +func NewUsersProviderService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Storage.Reva.Users.Supervised = true } return UsersProviderService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Storage, + cfg: cfg.Storage, } } -func (s UsersProviderService) Serve() { +func (s UsersProviderService) Serve(ctx context.Context) error { + s.cfg.Reva.Users.Context = ctx f := &flag.FlagSet{} for k := range Users(s.cfg).Flags { if err := Users(s.cfg).Flags[k].Apply(f); err != nil { - return + return err } } - ctx := cli.NewContext(nil, f, nil) + cliCtx := cli.NewContext(nil, f, nil) if Users(s.cfg).Before != nil { - if err := Users(s.cfg).Before(ctx); err != nil { - return + if err := Users(s.cfg).Before(cliCtx); err != nil { + return err } } - if err := Users(s.cfg).Action(ctx); err != nil { - return + if err := Users(s.cfg).Action(cliCtx); err != nil { + return err } -} -func (s UsersProviderService) Stop() { - s.cancel() + return nil } diff --git a/store/go.mod b/store/go.mod index c5febf1e8..292294b35 100644 --- a/store/go.mod +++ b/store/go.mod @@ -8,28 +8,17 @@ require ( contrib.go.opencensus.io/exporter/zipkin v0.1.2 github.com/asim/go-micro/v3 v3.5.1-0.20210217182006-0f0ace1a44a9 github.com/blevesearch/bleve v1.0.9 - github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d // indirect - github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect - github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 // indirect - github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect - github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect - github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect github.com/golang/protobuf v1.4.3 github.com/grpc-ecosystem/grpc-gateway/v2 v2.2.0 - github.com/imdario/mergo v0.3.11 // indirect - github.com/jmhodges/levigo v1.0.0 // indirect github.com/micro/cli/v2 v2.1.2 github.com/oklog/run v1.1.0 github.com/olekukonko/tablewriter v0.0.4 github.com/openzipkin/zipkin-go v0.2.5 github.com/owncloud/ocis/ocis-pkg v0.0.0-20210216094451-dc73176dc62d github.com/prometheus/client_golang v1.7.1 - github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/spf13/viper v1.7.1 - github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect - github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 - golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect google.golang.org/protobuf v1.25.0 ) diff --git a/store/go.sum b/store/go.sum index 76afe74b0..330df6c65 100644 --- a/store/go.sum +++ b/store/go.sum @@ -1520,9 +1520,10 @@ github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cb github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= -github.com/thejerf/suture v1.1.1 h1:Wg9YwKMlCIAa9XbEeFyrYDGF9OXq0f6hDl4bdy+mVdE= 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= @@ -1689,6 +1690,7 @@ golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c h1:9HhBz5L/UjnK9XLtiZhYAdue5BVKep3PMmS2LuPDt8k= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= @@ -1913,7 +1915,6 @@ golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b h1:lAZ0/chPUDWwjqosYR0X4M490zQhMsiJ4K3DbA7o+3g= golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -2024,9 +2025,8 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200811215021-48a8ffc5b207/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064 h1:BmCFkEH4nJrYcAc2L08yX5RhYGD4j58PTMkEUDkpz2I= golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2206,9 +2206,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k= honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.1.1 h1:EVDuO03OCZwpV2t/tLLxPmPiomagMoBOgfPt0FM+4IY= -honnef.co/go/tools v0.1.1/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= diff --git a/store/pkg/command/root.go b/store/pkg/command/root.go index dc31f37dd..63a20b4c8 100644 --- a/store/pkg/command/root.go +++ b/store/pkg/command/root.go @@ -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 } diff --git a/thumbnails/go.mod b/thumbnails/go.mod index ed0bff2e0..5cff5cf21 100644 --- a/thumbnails/go.mod +++ b/thumbnails/go.mod @@ -19,6 +19,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/thejerf/suture v4.0.0+incompatible + github.com/thejerf/suture/v4 v4.0.0 go.opencensus.io v0.23.0 golang.org/x/image v0.0.0-20190802002840-cff245a6509b google.golang.org/protobuf v1.25.0 diff --git a/thumbnails/go.sum b/thumbnails/go.sum index 3cc2bb042..fcf3aebf8 100644 --- a/thumbnails/go.sum +++ b/thumbnails/go.sum @@ -1493,6 +1493,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= @@ -1656,6 +1658,7 @@ golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c h1:9HhBz5L/UjnK9XLtiZhYAdue5BVKep3PMmS2LuPDt8k= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= diff --git a/thumbnails/pkg/command/root.go b/thumbnails/pkg/command/root.go index 9f9dff9f9..ec006eb5f 100644 --- a/thumbnails/pkg/command/root.go +++ b/thumbnails/pkg/command/root.go @@ -13,7 +13,7 @@ import ( "github.com/owncloud/ocis/thumbnails/pkg/config" "github.com/owncloud/ocis/thumbnails/pkg/version" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Execute is the entry point for the ocis-thumbnails command. @@ -113,31 +113,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the thumbnails 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 thumbnails.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Thumbnails.Context = sctx +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Thumbnails.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Thumbnails, + cfg: cfg.Thumbnails, } } -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 } diff --git a/web/go.mod b/web/go.mod index ea6756ff7..d7bfa347a 100644 --- a/web/go.mod +++ b/web/go.mod @@ -15,6 +15,7 @@ require ( github.com/owncloud/ocis/ocis-pkg v0.0.0-20210216094451-dc73176dc62d 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 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect golang.org/x/net v0.0.0-20201224014010-6772e930b67b diff --git a/web/go.sum b/web/go.sum index da195f797..082034be1 100644 --- a/web/go.sum +++ b/web/go.sum @@ -1483,6 +1483,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= diff --git a/web/pkg/command/root.go b/web/pkg/command/root.go index faa3b007e..0c0a2b3c6 100644 --- a/web/pkg/command/root.go +++ b/web/pkg/command/root.go @@ -13,7 +13,7 @@ import ( "github.com/owncloud/ocis/web/pkg/config" "github.com/owncloud/ocis/web/pkg/version" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Execute is the entry point for the web command. @@ -109,31 +109,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the web 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 web.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.Web.Context = sctx +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Web.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.Web, + cfg: cfg.Web, } } -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 } diff --git a/webdav/go.mod b/webdav/go.mod index fd4c7bdd6..aa84ef11b 100644 --- a/webdav/go.mod +++ b/webdav/go.mod @@ -18,7 +18,7 @@ require ( github.com/prometheus/client_golang v1.7.1 github.com/rivo/uniseg v0.2.0 // indirect 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 golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect golang.org/x/text v0.3.5 // indirect diff --git a/webdav/go.sum b/webdav/go.sum index 68d90599d..ce431bac2 100644 --- a/webdav/go.sum +++ b/webdav/go.sum @@ -829,6 +829,7 @@ github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhK github.com/ijc/Gotty v0.0.0-20170406111628-a8b993ba6abd/go.mod h1:3LVOLeyx9XVvwPgrt2be44XgSqndprz1G18rSk8KD84= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -1490,6 +1491,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= @@ -1652,6 +1655,7 @@ golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c h1:9HhBz5L/UjnK9XLtiZhYAdue5BVKep3PMmS2LuPDt8k= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= diff --git a/webdav/pkg/command/root.go b/webdav/pkg/command/root.go index 85652f6a9..ac52eafda 100644 --- a/webdav/pkg/command/root.go +++ b/webdav/pkg/command/root.go @@ -13,7 +13,7 @@ import ( "github.com/owncloud/ocis/webdav/pkg/config" "github.com/owncloud/ocis/webdav/pkg/version" "github.com/spf13/viper" - "github.com/thejerf/suture" + "github.com/thejerf/suture/v4" ) // Execute is the entry point for the ocis-webdav command. @@ -111,31 +111,24 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // SutureService allows for the webdav 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 webdav.SutureService -func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service { - sctx, cancel := context.WithCancel(ctx) - cfg.WebDAV.Context = sctx +func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.WebDAV.Supervised = true } return SutureService{ - ctx: sctx, - cancel: cancel, - cfg: cfg.WebDAV, + cfg: cfg.WebDAV, } } -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 }