Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Quick reference for terms used throughout the taskmill documentation.
| **Recurring task** | A task that automatically re-submits itself after each completion according to a `RecurringSchedule`. Recurring schedules survive restarts and support pause, resume, and cancel operations. See [Quick Start](quick-start.md#recurring-tasks). |
| **Typed task** | A struct that implements the `TypedTask` trait, giving you compile-time type safety for task payloads and configuration. Declares `type Domain: DomainKey` for compile-time domain identity and `fn config() -> TaskTypeConfig` for static defaults (priority, IO budget, TTL, retry policy, etc.). Register with `Domain::task::<T>(executor)` and submit with `handle.submit(task)`. See [Quick Start](quick-start.md#typed-tasks). |
| **TaskTypeConfig** | A struct returned by `TypedTask::config()` that holds static per-task-type defaults — priority, IO budget, group key, TTL, retry policy, duplicate strategy, etc. All fields are `Option`; `None` means "use the next layer's default" (domain default, then scheduler global, then built-in). |
| **DomainSubmitBuilder** | The fluent builder returned by `DomainHandle::submit_with(task)`. Implements `IntoFuture` so bare `.await` applies all defaults; chain override methods (`.priority()`, `.run_after()`, `.parent()`, etc.) before `.await` to override individual fields for that call only. |
| **DomainSubmitBuilder** | The fluent builder returned by `DomainHandle::submit_with(task)`. Implements `IntoFuture` so bare `.await` applies all defaults; chain override methods (`.priority()`, `.run_after()`, `.parent()`, `.fail_fast()`, etc.) before `.await` to override individual fields for that call only. |
| **Domain-scoped state** | Application state registered on a `Domain` via `.state(value)`, visible only to executors within that domain. `TaskContext::state::<T>()` checks domain state first and falls back to global state registered on `SchedulerBuilder`. See [Configuration](configuration.md#application-state). |
| **TypedEventStream** | A per-task-type event subscription (`TypedEventStream<T>`) created via `handle.task_events::<T>()`. Filters the global scheduler event broadcast to only events matching `T::TASK_TYPE` within the domain. Terminal events include the `TaskHistoryRecord`. |
| **Qualified task type** | The full database-stored task type including the domain prefix, e.g. `"media::thumbnail"`. Required when using store-level query APIs (`history_stats`, `task_lookup`, `avg_throughput`). `DomainHandle` methods apply the prefix automatically, so you typically only need the short form when submitting tasks. |
Expand Down
15 changes: 14 additions & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,20 @@ ctx.domain::<Storage>()
.await?;
```

By default, if any child fails, its siblings are cancelled and the parent fails immediately (fail-fast). Disable this per-submission with `.fail_fast(false)`.
By default, if any child fails, its siblings are cancelled and the parent fails immediately (fail-fast). Disable this per-submission with `.fail_fast(false)`:

```rust
// Typed builder
media.submit_with(ScanTask { .. })
.fail_fast(false)
.await?;

// Untyped
scheduler.submit(
TaskSubmission::new("scan")
.fail_fast(false)
).await?;
```

## Sharing the scheduler

Expand Down
9 changes: 9 additions & 0 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,15 @@ impl<D: DomainKey> DomainSubmitBuilder<D> {
self
}

/// Control whether a child failure immediately fails the parent.
///
/// Defaults to `true`. Set to `false` to let the parent's `finalize()`
/// run even when some children fail.
pub fn fail_fast(mut self, fail_fast: bool) -> Self {
self.inner = self.inner.fail_fast(fail_fast);
self
}

/// Set the parent task ID.
pub fn parent(mut self, id: i64) -> Self {
self.inner = self.inner.parent(id);
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
//! [`TypedExecutor::finalize`] method is called — useful for assembly work
//! like `CompleteMultipartUpload`. If any child fails and
//! [`fail_fast`](TaskSubmission::fail_fast) is `true` (the default), siblings
//! are cancelled and the parent fails immediately.
//! are cancelled and the parent fails immediately. Disable this with
//! [`DomainSubmitBuilder::fail_fast(false)`](DomainSubmitBuilder::fail_fast)
//! (or [`TaskSubmission::fail_fast`] for untyped submissions).
//!
//! ## Task TTL & automatic expiry
//!
Expand Down
14 changes: 14 additions & 0 deletions src/task/submit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub struct SubmitBuilder {
override_on_dependency_failure: Option<DependencyFailurePolicy>,
override_tags: HashMap<String, String>,
override_parent_id: Option<i64>,
override_fail_fast: Option<bool>,
}

impl SubmitBuilder {
Expand Down Expand Up @@ -140,6 +141,7 @@ impl SubmitBuilder {
override_on_dependency_failure: None,
override_tags: HashMap::new(),
override_parent_id: None,
override_fail_fast: None,
}
}

Expand Down Expand Up @@ -212,6 +214,15 @@ impl SubmitBuilder {
self
}

/// Control whether a child failure immediately fails the parent.
///
/// Defaults to `true`. Set to `false` to let the parent's `finalize()`
/// run even when some children fail.
pub fn fail_fast(mut self, fail_fast: bool) -> Self {
self.override_fail_fast = Some(fail_fast);
self
}

/// Set the parent task ID for hierarchical tasks (parent-child
/// relationship). This does **not** establish a dependency — use
/// [`depends_on`](Self::depends_on) for that.
Expand Down Expand Up @@ -349,6 +360,9 @@ impl SubmitBuilder {
if let Some(pid) = self.override_parent_id.take() {
self.submission.parent_id = Some(pid);
}
if let Some(ff) = self.override_fail_fast.take() {
self.submission.fail_fast = ff;
}
}

/// Submit the task, returning the outcome.
Expand Down
Loading