(ctx context.Context, params *riverdriver.JobCancelParams)
| 249 | } |
| 250 | |
| 251 | func (e *Executor) JobCancel(ctx context.Context, params *riverdriver.JobCancelParams) (*rivertype.JobRow, error) { |
| 252 | // Unlike Postgres, this must be carried out in two operations because |
| 253 | // SQLite doesn't support CTEs containing `UPDATE`. As long as the job |
| 254 | // exists and is not running, only one database operation is needed, but if |
| 255 | // the initial update comes back empty, it does one more fetch to return the |
| 256 | // most appropriate error. |
| 257 | return dbutil.WithTxV(ctx, e, func(ctx context.Context, execTx riverdriver.ExecutorTx) (*rivertype.JobRow, error) { // TODO |
| 258 | dbtx := templateReplaceWrapper{dbtx: e.driver.UnwrapTx(execTx), replacer: &e.driver.replacer} |
| 259 | |
| 260 | cancelledAt, err := params.CancelAttemptedAt.UTC().MarshalJSON() |
| 261 | if err != nil { |
| 262 | return nil, err |
| 263 | } |
| 264 | cancelledAt = cancelledAt[1 : len(cancelledAt)-1] // remove quotes around the time so we don't end up with doubled up quotes |
| 265 | |
| 266 | job, err := dbsqlc.New().JobCancel(schemaTemplateParam(ctx, params.Schema), dbtx, &dbsqlc.JobCancelParams{ |
| 267 | ID: params.ID, |
| 268 | CancelAttemptedAt: string(cancelledAt), |
| 269 | Now: timeStringNullable(params.Now), |
| 270 | }) |
| 271 | if err != nil { |
| 272 | if errors.Is(err, sql.ErrNoRows) { |
| 273 | job, err := execTx.JobGetByID(ctx, &riverdriver.JobGetByIDParams{ |
| 274 | ID: params.ID, |
| 275 | Schema: params.Schema, |
| 276 | }) |
| 277 | if err != nil { |
| 278 | return nil, interpretError(err) |
| 279 | } |
| 280 | return job, nil |
| 281 | } |
| 282 | |
| 283 | return nil, interpretError(err) |
| 284 | } |
| 285 | return jobRowFromInternal(job) |
| 286 | }) |
| 287 | } |
| 288 | |
| 289 | func (e *Executor) JobCountByAllStates(ctx context.Context, params *riverdriver.JobCountByAllStatesParams) (map[rivertype.JobState]int, error) { |
| 290 | counts, err := dbsqlc.New().JobCountByAllStates(schemaTemplateParam(ctx, params.Schema), e.dbtx) |
nothing calls this directly
no test coverage detected