Skip to content

Commit

Permalink
rename Catnip to Run and add context param
Browse files Browse the repository at this point in the history
  • Loading branch information
noriah committed Dec 24, 2022
1 parent 1ba7db1 commit 88e8871
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 1 addition & 5 deletions catnip.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type SetupFunc func() error
type StartFunc func(ctx context.Context) (context.Context, error)
type CleanupFunc func() error

func Catnip(cfg *Config) error {
func Run(cfg *Config, ctx context.Context) error {
if err := cfg.Validate(); err != nil {
return err
}
Expand Down Expand Up @@ -77,10 +77,6 @@ func Catnip(cfg *Config) error {
defer cfg.CleanupFunc()
}

// Root Context
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

if cfg.StartFunc != nil {
if ctx, err = cfg.StartFunc(ctx); err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion cmd/catnip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func main() {
}),
}

chk(catnip.Catnip(&catnipCfg), "failed to run catnip")
// Root Context
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

chk(catnip.Run(&catnipCfg, ctx), "failed to run catnip")
}

func doFlags(cfg *config) bool {
Expand Down

0 comments on commit 88e8871

Please sign in to comment.