MCPcopy Create free account
hub / github.com/riverqueue/river / Work

Method Work

rivertest/worker.go:104–112  ·  view source on GitHub ↗

Work inserts a job with the provided arguments and optional insert options, then works it. The transaction is used for all work-related database operations so that the caller can easily roll back at the end of the test to maintain a clean database state. The returned WorkResult contains the updated

(ctx context.Context, tb testing.TB, tx TTx, args T, opts *river.InsertOpts)

Source from the content-addressed store, hash-verified

102// The returned error only reflects _real_ errors and does not include
103// explicitly returned snooze or cancel errors from the worker.
104func (w *Worker[T, TTx]) Work(ctx context.Context, tb testing.TB, tx TTx, args T, opts *river.InsertOpts) (*WorkResult, error) {
105 tb.Helper()
106
107 job, err := w.insertJob(ctx, tb, tx, args, opts)
108 if err != nil {
109 return nil, fmt.Errorf("failed to insert job: %w", err)
110 }
111 return w.WorkJob(ctx, tb, tx, job)
112}
113
114// WorkJob works an existing job already in the database. The job must be
115// inserted using external logic prior to calling this method. The transaction

Callers

nothing calls this directly

Calls 4

insertJobMethod · 0.95
WorkJobMethod · 0.95
HelperMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected