leftover comment

This commit is contained in:
A.Unger
2021-03-04 14:58:19 +01:00
parent cea043c2ac
commit 255fc4bc92
2 changed files with 53 additions and 11 deletions
+41
View File
@@ -2,6 +2,7 @@ package command
import (
"context"
"flag"
"os"
"os/signal"
"path"
@@ -205,3 +206,43 @@ 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
}
// NewUsersProviderService creates a new gateway.UsersProviderService
func NewUsersProviderService(ctx context.Context, cfg *config.Config) UsersProviderService {
sctx, cancel := context.WithCancel(ctx)
cfg.Context = sctx
return UsersProviderService{
ctx: sctx,
cancel: cancel,
cfg: cfg,
}
}
func (s UsersProviderService) Serve() {
f := &flag.FlagSet{}
for k := range Users(s.cfg).Flags {
if err := Users(s.cfg).Flags[k].Apply(f); err != nil {
return
}
}
ctx := 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).Action(ctx); err != nil {
return
}
}
func (s UsersProviderService) Stop() {
s.cancel()
}