Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Resuming an already unpaused queue is now fully an no-op, and won't touch the row's `updated_at` like it (unintentionally) did before. [PR #870](https://github.com/riverqueue/river/pull/870).
- Suppress an error log line from the producer that may occur on normal shutdown when operating in poll-only mode. [PR #896](https://github.com/riverqueue/river/pull/896).

## [0.22.0] - 2025-05-10

Expand Down
26 changes: 14 additions & 12 deletions producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,21 @@ func (p *producer) pollForSettingChanges(ctx context.Context, wg *sync.WaitGroup
case <-ctx.Done():
return
case <-ticker.C:
updatedQueue, err := p.fetchQueueSettings(ctx)
updatedQueue, err := func() (*rivertype.Queue, error) {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()

return p.exec.QueueGet(ctx, &riverdriver.QueueGetParams{
Name: p.config.Queue,
Schema: p.config.Schema,
})
}()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bgentry Are you okay on inlining some of these trivial functions like this? IMO makes it easier to see what it's going to do without having to go search for the helper's implementation elsewhere in the file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok, the tradeoff is that stack traces lose some context. But for this particular one I don't think it matters much since the trace will still point to a polling-specific function name.

if err != nil {
p.Logger.ErrorContext(ctx, p.Name+": Error fetching queue settings", slog.String("err", err.Error()))
// Don't log if this is part of a standard shutdown.
if !errors.Is(context.Cause(ctx), startstop.ErrStop) {
p.Logger.ErrorContext(ctx, p.Name+": Error fetching queue settings", slog.String("err", err.Error()))

}
continue
}

Expand Down Expand Up @@ -857,16 +869,6 @@ func (p *producer) pollForSettingChanges(ctx context.Context, wg *sync.WaitGroup
}
}

func (p *producer) fetchQueueSettings(ctx context.Context) (*rivertype.Queue, error) {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()

return p.exec.QueueGet(ctx, &riverdriver.QueueGetParams{
Name: p.config.Queue,
Schema: p.config.Schema,
})
}

func (p *producer) reportProducerStatusLoop(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()

Expand Down
Loading