Skip to content

Commit

Permalink
[chore] Remove parent setting / getting in Context wrapper (#1516)
Browse files Browse the repository at this point in the history
* [chore] Remove parent setting / getting in Context wrapper

* Keep the cancellable context from errgroup
  • Loading branch information
mcastorina authored Jul 20, 2023
1 parent 20b7793 commit 8ec5e49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@ var (
type Context interface {
context.Context
Logger() logr.Logger
Parent() context.Context
SetParent(ctx context.Context) Context
}

// Parent returns the parent context.
func (l logCtx) Parent() context.Context {
return l.Context
}

// SetParent sets the parent context on the context.
func (l logCtx) SetParent(ctx context.Context) Context {
l.Context = ctx
return l
}

type CancelFunc context.CancelFunc
// CancelFunc is a type alias to context.CancelFunc to allow use as if they are
// the same types.
type CancelFunc = context.CancelFunc

// logCtx implements Context.
type logCtx struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func Start(ctx context.Context, options ...EngineOption) *Engine {
sourcesWg, egCtx := errgroup.WithContext(ctx)
sourcesWg.SetLimit(e.concurrency)
e.sourcesWg = sourcesWg
ctx.SetParent(egCtx)
ctx = context.WithLogger(egCtx, ctx.Logger())

if len(e.decoders) == 0 {
e.decoders = decoders.DefaultDecoders()
Expand Down

0 comments on commit 8ec5e49

Please sign in to comment.