Skip to content

Commit cc1c466

Browse files
committed
fix: range over channel, add continue to default switch case
1 parent 67329a1 commit cc1c466

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

coderd/autostart/lifecycle/lifecycle_executor.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,9 @@ func NewExecutor(ctx context.Context, db database.Store, log slog.Logger, tick <
3838
// tick from its channel. It will stop when its context is Done, or when
3939
// its channel is closed.
4040
func (e *Executor) Run() {
41-
for {
42-
select {
43-
case t := <-e.tick:
44-
if err := e.runOnce(t); err != nil {
45-
e.log.Error(e.ctx, "error running once", slog.Error(err))
46-
}
47-
case <-e.ctx.Done():
48-
return
49-
default:
41+
for t := range e.tick {
42+
if err := e.runOnce(t); err != nil {
43+
e.log.Error(e.ctx, "error running once", slog.Error(err))
5044
}
5145
}
5246
}
@@ -94,6 +88,7 @@ func (e *Executor) runOnce(t time.Time) error {
9488
slog.F("workspace_id", ws.ID),
9589
slog.F("latest_build_transition", latestBuild.Transition),
9690
)
91+
continue
9792
}
9893

9994
// Round time to the nearest minute, as this is the finest granularity cron supports.

0 commit comments

Comments
 (0)