Skip to content

Commit

Permalink
repeater context with done chan
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Feb 3, 2025
1 parent 6b25d26 commit 9c21116
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/repeater/repeater.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ func New(
task func(ctx context.Context) (err error),
opts ...option,
) *repeater {
ctx, cancel := xcontext.WithCancel(ctx)
stopped := make(chan struct{})

ctx, cancel := xcontext.WithDone(ctx, stopped)

r := &repeater{
interval: interval,
task: task,
cancel: cancel,
stopped: make(chan struct{}),
stopped: stopped,
force: make(chan struct{}, 1),
clock: clockwork.NewRealClock(),
trace: &trace.Driver{},
Expand Down

0 comments on commit 9c21116

Please sign in to comment.