Skip to content

Commit 01a64a6

Browse files
committed
add JobRetry to Pilot interface
Allow Pro pilot to further customize this behavior.
1 parent 5341d91 commit 01a64a6

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,11 +1412,7 @@ func (c *Client[TTx]) JobGetTx(ctx context.Context, tx TTx, id int64) (*rivertyp
14121412
// MaxAttempts is also incremented by one if the job has already exhausted its
14131413
// max attempts.
14141414
func (c *Client[TTx]) JobRetry(ctx context.Context, id int64) (*rivertype.JobRow, error) {
1415-
return c.driver.GetExecutor().JobRetry(ctx, &riverdriver.JobRetryParams{
1416-
ID: id,
1417-
Now: c.baseService.Time.NowUTCOrNil(),
1418-
Schema: c.config.Schema,
1419-
})
1415+
return c.jobRetry(ctx, c.driver.GetExecutor(), id)
14201416
}
14211417

14221418
// JobRetryTx updates the job with the given ID to make it immediately available
@@ -1433,7 +1429,11 @@ func (c *Client[TTx]) JobRetry(ctx context.Context, id int64) (*rivertype.JobRow
14331429
// MaxAttempts is also incremented by one if the job has already exhausted its
14341430
// max attempts.
14351431
func (c *Client[TTx]) JobRetryTx(ctx context.Context, tx TTx, id int64) (*rivertype.JobRow, error) {
1436-
return c.driver.UnwrapExecutor(tx).JobRetry(ctx, &riverdriver.JobRetryParams{
1432+
return c.jobRetry(ctx, c.driver.UnwrapExecutor(tx), id)
1433+
}
1434+
1435+
func (c *Client[TTx]) jobRetry(ctx context.Context, exec riverdriver.Executor, id int64) (*rivertype.JobRow, error) {
1436+
return c.pilot.JobRetry(ctx, exec, &riverdriver.JobRetryParams{
14371437
ID: id,
14381438
Now: c.baseService.Time.NowUTCOrNil(),
14391439
Schema: c.config.Schema,

rivershared/riverpilot/pilot.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ type Pilot interface {
3232
params *riverdriver.JobInsertFastManyParams,
3333
) ([]*riverdriver.JobInsertFastResult, error)
3434

35+
JobRetry(ctx context.Context, exec riverdriver.Executor, params *riverdriver.JobRetryParams) (*rivertype.JobRow, error)
36+
3537
JobSetStateIfRunningMany(ctx context.Context, exec riverdriver.Executor, params *riverdriver.JobSetStateIfRunningManyParams) ([]*rivertype.JobRow, error)
3638

3739
PilotInit(archetype *baseservice.Archetype)

rivershared/riverpilot/standard.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ func (p *StandardPilot) JobInsertMany(
2828
return exec.JobInsertFastMany(ctx, params)
2929
}
3030

31+
func (p *StandardPilot) JobRetry(ctx context.Context, exec riverdriver.Executor, params *riverdriver.JobRetryParams) (*rivertype.JobRow, error) {
32+
return exec.JobRetry(ctx, params)
33+
}
34+
3135
func (p *StandardPilot) JobSetStateIfRunningMany(ctx context.Context, exec riverdriver.Executor, params *riverdriver.JobSetStateIfRunningManyParams) ([]*rivertype.JobRow, error) {
3236
return exec.JobSetStateIfRunningMany(ctx, params)
3337
}

0 commit comments

Comments
 (0)