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

Function ResumableStep

resumable.go:57–84  ·  view source on GitHub ↗

ResumableStep runs a resumable step, skipping the step on a later retry if an earlier attempt already completed it successfully. Step names must be unique across all ResumableStep and ResumableStepCursor calls in the same Worker execution. After a step returns an error, no subsequent steps will be

(ctx context.Context, name string, opts *StepOpts, stepFunc func(ctx context.Context) error)

Source from the content-addressed store, hash-verified

55//
56// opts may be nil.
57func ResumableStep(ctx context.Context, name string, opts *StepOpts, stepFunc func(ctx context.Context) error) {
58 state := mustResumableState(ctx)
59 if state.Err != nil {
60 return
61 }
62 if !registerResumableStepName(state, name) {
63 return
64 }
65
66 if !state.ResumeMatched {
67 if name == state.ResumeStep {
68 state.CompletedStep = name
69 state.ResumeMatched = true
70 }
71 return
72 }
73
74 previousStepName := state.StepName
75 state.StepName = name
76 defer func() { state.StepName = previousStepName }()
77
78 if err := stepFunc(ctx); err != nil {
79 state.Err = err
80 return
81 }
82
83 state.CompletedStep = name
84}
85
86// ResumableStepCursor runs a resumable step that also receives a persisted
87// cursor value from an earlier failed attempt, if one was recorded with

Callers 6

WorkMethod · 0.92
WorkMethod · 0.92
TestResumableStepFunction · 0.85
TestResumableStepCursorFunction · 0.85
WorkMethod · 0.85

Calls 2

mustResumableStateFunction · 0.85

Tested by 6

WorkMethod · 0.74
WorkMethod · 0.74
TestResumableStepFunction · 0.68
TestResumableStepCursorFunction · 0.68
WorkMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…