(ctx context.Context, params *riverdriver.JobDeleteParams)
| 358 | } |
| 359 | |
| 360 | func (e *Executor) JobDelete(ctx context.Context, params *riverdriver.JobDeleteParams) (*rivertype.JobRow, error) { |
| 361 | // Unlike Postgres, this must be carried out in two operations because |
| 362 | // SQLite doesn't support CTEs containing `DELETE`. As long as the job |
| 363 | // exists and is not running, only one database operation is needed, but if |
| 364 | // the initial delete comes back empty, it does one more fetch to return the |
| 365 | // most appropriate error. |
| 366 | return dbutil.WithTxV(ctx, e, func(ctx context.Context, execTx riverdriver.ExecutorTx) (*rivertype.JobRow, error) { // TODO |
| 367 | dbtx := templateReplaceWrapper{dbtx: e.driver.UnwrapTx(execTx), replacer: &e.driver.replacer} |
| 368 | |
| 369 | job, err := dbsqlc.New().JobDelete(schemaTemplateParam(ctx, params.Schema), dbtx, params.ID) |
| 370 | if err != nil { |
| 371 | if errors.Is(err, sql.ErrNoRows) { |
| 372 | job, err := execTx.JobGetByID(ctx, (*riverdriver.JobGetByIDParams)(params)) |
| 373 | if err != nil { |
| 374 | return nil, err |
| 375 | } |
| 376 | if job.State == rivertype.JobStateRunning { |
| 377 | return nil, rivertype.ErrJobRunning |
| 378 | } |
| 379 | return nil, fmt.Errorf("bug; expected only to fetch a job with state %q, but was: %q", rivertype.JobStateRunning, job.State) |
| 380 | } |
| 381 | |
| 382 | return nil, interpretError(err) |
| 383 | } |
| 384 | return jobRowFromInternal(job) |
| 385 | }) |
| 386 | } |
| 387 | |
| 388 | func (e *Executor) JobDeleteBefore(ctx context.Context, params *riverdriver.JobDeleteBeforeParams) (int, error) { |
| 389 | if len(params.QueuesIncluded) > 0 { |
nothing calls this directly
no test coverage detected