VCST-5686: Add on-demand job cancellation - #3097
Open
OlegoO wants to merge 6 commits into
Open
Conversation
Add on-demand job cancellation to the engine-agnostic background-jobs API.
Two default interface members on IBackgroundJob, plus the static BackgroundJob counterparts:
```cs
Task<bool> Cancel(string jobId, CancellationToken ct = default); // default: false
bool SupportsCancellation { get; }
```
AddRecurringJob had no way to express [AutomaticRetry(Attempts = 0)], which several migrated recurring jobs (image-tools ProcessAll, search IndexChangesJob) carried under Hangfire: EnqueueOptions is built by the schedule builder, and the builder only exposed the queue. WithMaxRetryAttempts(n) flows into that EnqueueOptions, so a schedule can opt out of retries — a scheduled run that failed is superseded by the next occurrence. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The cancellation commit dropped the XML docs from both Enqueue members and added Cancel/SupportsCancellation with none, leaving the facade — the one type module authors read before writing a job — undocumented. Restores the Enqueue docs verbatim and documents the two new members: what Cancel returns and why SupportsCancellation must be probed first, so an engine that cannot cancel degrades visibly instead of accepting a request that does nothing. Adds Platform.Core tests for the recurring schedule builder covering the new WithMaxRetryAttempts alongside the existing queue option. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
|
basilkot
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Add on-demand job cancellation to the engine-agnostic background-jobs API.
Two default interface members on IBackgroundJob, plus the static BackgroundJob counterparts:
Description
References
QA-test:
Jira-link:
https://virtocommerce.atlassian.net/browse/VCST-5686
Artifact URL:
Note
Medium Risk
Public job API changes affect how callers stop in-flight work; defaults are safe, but real cancellation behavior depends on the engine implementation outside this diff.
Overview
Adds an engine-agnostic on-demand cancellation surface on
IBackgroundJob(Cancelreturning whether cancellation was requested, andSupportsCancellation), with default no-op behavior so existing engines keep working until they override. The staticBackgroundJobfacade gets matchingCancelandSupportsCancellationmembers that resolveIBackgroundJobthrough a scoped provider (uninitialized facade yieldsfalsefor support, same pattern as enqueue).Recurring schedules can now declare
WithMaxRetryAttempts, which flows intoEnqueueOptionson each trigger (combined with queue when set; stillnulloptions when neither queue nor retries are configured).IBackgroundJobXML documentation is trimmed on the interface; behavior of enqueue overloads is unchanged.New unit tests assert recurring builder →
EnqueueOptionswiring for retries, queue combination, and negative retry rejection.Reviewed by Cursor Bugbot for commit 3559772. Bugbot is set up for automated code reviews on this repo. Configure here.
Image tag:
ghcr.io/VirtoCommerce/platform:3.1059.0-pr-3097-3559-vcst-5686-3559772a