Migrating to v0.30¶
v0.30 adds batch enqueueing to the job queue. The feature itself is additive —
the one breaking change is that the Enqueuer interface (and therefore Queue)
gains two methods, which affects custom implementations and test mocks.
For the full list of changes, see the v0.30 changelog.
Quick orientation¶
| What you used | What changes | Section |
|---|---|---|
contrib/jobs as your Queue |
Nothing — new methods are provided | — |
A custom Enqueuer/Queue implementation or test mock |
Must add EnqueueBatch + EnqueueBatchAt |
Enqueuer interface |
| Den v0.17.0 | Bumped to v0.17.1 (transitive bugfix: SQLite FTS backfill) | — |
| (nothing) | New EnqueueBatch/EnqueueBatchAt on tasks and the queue |
New: batch enqueueing |
Enqueuer gains batch methods¶
tasks.Enqueuer now includes EnqueueBatch and EnqueueBatchAt. Anything
implementing Enqueuer or Queue — typically test mocks — needs both:
// Add to your mock/implementation:
func (q *mockQueue) EnqueueBatch(ctx context.Context, typeName string, payloads []any) ([]string, error) {
return q.EnqueueBatchAt(ctx, typeName, payloads, time.Now())
}
func (q *mockQueue) EnqueueBatchAt(ctx context.Context, typeName string, payloads []any, runAt time.Time) ([]string, error) {
if len(payloads) == 0 {
return nil, nil
}
ids := make([]string, len(payloads))
for i := range payloads {
ids[i] = fmt.Sprintf("job-%d", i+1) // record/stub as your test needs
}
return ids, nil
}
The contract for real implementations: the insert is atomic (all payloads
become jobs or none do), IDs return in input order, and an empty slice returns
(nil, nil) without touching the queue.
New: batch enqueueing¶
Nothing to migrate — EnqueueBatch/EnqueueBatchAt insert N jobs of one type
in a single transaction, on the typed task wrappers and the raw queue alike.
See the Jobs guide.