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

Method Work

client_test.go:104–139  ·  view source on GitHub ↗
(ctx context.Context, job *Job[resumableClientTestArgs])

Source from the content-addressed store, hash-verified

102}
103
104func (w *resumableClientTestWorker) Work(ctx context.Context, job *Job[resumableClientTestArgs]) error {
105 appendCall := func(call string) {
106 w.callsMu.Lock()
107 defer w.callsMu.Unlock()
108
109 w.calls = append(w.calls, call)
110 }
111
112 ResumableStep(ctx, "step1", nil, func(ctx context.Context) error {
113 appendCall("step1")
114 return nil
115 })
116
117 ResumableStepCursor(ctx, "step2", nil, func(ctx context.Context, cursor int) error {
118 appendCall("step2:" + strconv.Itoa(cursor))
119
120 for itemID := cursor + 1; itemID <= 2; itemID++ {
121 appendCall("item:" + strconv.Itoa(itemID))
122 if err := ResumableSetCursor(ctx, itemID); err != nil {
123 return err
124 }
125 if !w.failedOnce.Swap(true) {
126 return errors.New("retry me")
127 }
128 }
129
130 return nil
131 })
132
133 ResumableStep(ctx, "step3", nil, func(ctx context.Context) error {
134 appendCall("step3")
135 return nil
136 })
137
138 return nil
139}
140
141func makeAwaitWorker[T JobArgs](startedCh chan<- int64, doneCh chan struct{}) Worker[T] {
142 return WorkFunc(func(ctx context.Context, job *Job[T]) error {

Callers

nothing calls this directly

Calls 3

ResumableStepFunction · 0.85
ResumableStepCursorFunction · 0.85
ResumableSetCursorFunction · 0.85

Tested by

no test coverage detected