newRiverClient creates a barebones client to connect to river to rerun jobs
(ctx context.Context, dsn string)
| 247 | |
| 248 | // newRiverClient creates a barebones client to connect to river to rerun jobs |
| 249 | func newRiverClient(ctx context.Context, dsn string) (*river.Client[pgx.Tx], error) { |
| 250 | dbPool, err := pgxpool.New(ctx, dsn) |
| 251 | if err != nil { |
| 252 | return nil, err |
| 253 | } |
| 254 | |
| 255 | tx, err := dbPool.Begin(ctx) |
| 256 | if err != nil { |
| 257 | return nil, err |
| 258 | } |
| 259 | defer func() { _ = tx.Rollback(ctx) }() |
| 260 | |
| 261 | riverClient, err := river.NewClient(riverpgxv5.New(dbPool), &river.Config{ |
| 262 | JobTimeout: time.Hour, |
| 263 | MaxAttempts: 3, // default retry policy with backoff of attempt^4 seconds |
| 264 | }) |
| 265 | if err != nil { |
| 266 | return nil, err |
| 267 | } |
| 268 | |
| 269 | return riverClient, nil |
| 270 | } |
no test coverage detected