MCPcopy Index your code
hub / github.com/riverqueue/river / Work

Method Work

example_resumable_cursor_job_test.go:33–51  ·  view source on GitHub ↗
(ctx context.Context, job *river.Job[ResumableCursorArgs])

Source from the content-addressed store, hash-verified

31}
32
33func (w *ResumableCursorWorker) Work(ctx context.Context, job *river.Job[ResumableCursorArgs]) error {
34 river.ResumableStepCursor(ctx, "process_ids", nil, func(ctx context.Context, cursor ResumableCursor) error {
35 for _, id := range job.Args.IDs {
36 if id <= cursor.LastProcessedID {
37 continue
38 }
39
40 fmt.Printf("Processed %d\n", id)
41
42 if err := river.ResumableSetCursor(ctx, ResumableCursor{LastProcessedID: id}); err != nil {
43 return err
44 }
45 }
46
47 return nil
48 })
49
50 return nil
51}
52
53// Example_resumableCursor demonstrates the use of a resumable cursor step, a
54// step that can store arbitrary JSON state to resume a partially completed loop.

Callers

nothing calls this directly

Calls 2

ResumableStepCursorFunction · 0.92
ResumableSetCursorFunction · 0.92

Tested by

no test coverage detected