ResumableSetStepCursorTx immediately persists the current resumable step and cursor as part of transaction tx. If tx is rolled back, the step and cursor update will be as well. Normally, a resumable job's step progress is recorded after it runs along with its result status. This is normally suffici
(ctx context.Context, tx TTx, job *Job[TArgs], cursor TCursor)
| 43 | // Must be called from within a ResumableStepCursor callback. The current step |
| 44 | // name to persist is read from context. |
| 45 | func ResumableSetStepCursorTx[TDriver riverdriver.Driver[TTx], TTx any, TArgs JobArgs, TCursor any](ctx context.Context, tx TTx, job *Job[TArgs], cursor TCursor) (*Job[TArgs], error) { |
| 46 | cursorBytes, err := json.Marshal(cursor) |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | |
| 51 | return resumableSetStepTx(ctx, tx, job, json.RawMessage(cursorBytes)) |
| 52 | } |
| 53 | |
| 54 | func resumableSetStepTx[TTx any, TArgs JobArgs](ctx context.Context, tx TTx, job *Job[TArgs], cursor json.RawMessage) (*Job[TArgs], error) { |
| 55 | if job.State != rivertype.JobStateRunning { |
searching dependent graphs…