(ctx context.Context, job *Job[resumableClientTestArgs])
| 102 | } |
| 103 | |
| 104 | func (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 | |
| 141 | func makeAwaitWorker[T JobArgs](startedCh chan<- int64, doneCh chan struct{}) Worker[T] { |
| 142 | return WorkFunc(func(ctx context.Context, job *Job[T]) error { |
nothing calls this directly
no test coverage detected