Skip to content

Commit 88e8871

Browse files
committed
rename Catnip to Run and add context param
1 parent 1ba7db1 commit 88e8871

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

catnip.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type SetupFunc func() error
1414
type StartFunc func(ctx context.Context) (context.Context, error)
1515
type CleanupFunc func() error
1616

17-
func Catnip(cfg *Config) error {
17+
func Run(cfg *Config, ctx context.Context) error {
1818
if err := cfg.Validate(); err != nil {
1919
return err
2020
}
@@ -77,10 +77,6 @@ func Catnip(cfg *Config) error {
7777
defer cfg.CleanupFunc()
7878
}
7979

80-
// Root Context
81-
ctx, cancel := context.WithCancel(context.Background())
82-
defer cancel()
83-
8480
if cfg.StartFunc != nil {
8581
if ctx, err = cfg.StartFunc(ctx); err != nil {
8682
return err

cmd/catnip/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ func main() {
8787
}),
8888
}
8989

90-
chk(catnip.Catnip(&catnipCfg), "failed to run catnip")
90+
// Root Context
91+
ctx, cancel := context.WithCancel(context.Background())
92+
defer cancel()
93+
94+
chk(catnip.Run(&catnipCfg, ctx), "failed to run catnip")
9195
}
9296

9397
func doFlags(cfg *config) bool {

0 commit comments

Comments
 (0)