Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

job: Close the health reporter instead of stopping #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion job/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func (jo *jobObserver[T]) start(ctx context.Context, wg *sync.WaitGroup, health
}

jo.health = health.NewScope("observer-job-" + jo.name)
defer jo.health.Close()

reportTicker := time.NewTicker(10 * time.Second)
defer reportTicker.Stop()

Expand Down Expand Up @@ -121,7 +123,6 @@ func (jo *jobObserver[T]) start(ctx context.Context, wg *sync.WaitGroup, health

<-done

jo.health.Stopped("observer job done")
if err != nil {
l.Error("Observer job stopped with an error", "error", err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion job/oneshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (jos *jobOneShot) start(ctx context.Context, wg *sync.WaitGroup, health cel
}

jos.health = health.NewScope("job-" + jos.name)
defer jos.health.Stopped("one-shot job done")
defer jos.health.Close()

l := options.logger.With(
"name", jos.name,
Expand Down
2 changes: 1 addition & 1 deletion job/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (jt *jobTimer) start(ctx context.Context, wg *sync.WaitGroup, health cell.H
}

jt.health = health.NewScope("timer-job-" + jt.name)
defer jt.health.Close()

l := options.logger.With(
"name", jt.name,
Expand All @@ -175,7 +176,6 @@ func (jt *jobTimer) start(ctx context.Context, wg *sync.WaitGroup, health cell.H
for {
select {
case <-ctx.Done():
jt.health.Stopped("timer job context done")
return
case <-tickerChan:
case <-triggerChan:
Expand Down
Loading