#[task]Expand description
Define a Rustvello task from a function.
Generates a params struct (if the function has parameters), a task struct,
and a Task trait implementation.
§Basic usage
ⓘ
#[rustvello::task]
fn add(x: i32, y: i32) -> i32 {
x + y
}This generates:
AddParams— a serializable struct with fieldsx: i32, y: i32AddTask— a unit struct implementingTask- The original
addfunction is preserved for direct calls
§Configuration
ⓘ
#[rustvello::task(max_retries = 3)]
fn process(data: String) -> String {
data.to_uppercase()
}§Fallible tasks
If the function returns Result<T, _> or RustvelloResult<T>, the
macro extracts T as the task’s result type and passes the function’s
return value through without wrapping in Ok.
ⓘ
#[rustvello::task]
fn divide(x: f64, y: f64) -> RustvelloResult<f64> {
if y == 0.0 {
return Err(RustvelloError::runner_err("division by zero".into()));
}
Ok(x / y)
}§Supported attributes
| Attribute | Type | Description |
|---|---|---|
max_retries | u32 | Maximum retry attempts (default: 0) |
module | &str | Override module in TaskId |
concurrency | &str | Concurrency control: “unlimited” |
registration_concurrency | &str | Registration-time concurrency control |
key_arguments | [&str] | Parameter names used as concurrency keys |
cache_results | bool | Cache results for identical arguments |
disable_cache_args | [&str] | Arg names to exclude from cache key |
retry_for_errors | [&str] | Error type names that trigger retries |
on_diff_non_key_args_raise | bool | Raise on non-key arg mismatch |
parallel_batch_size | usize | Batch size for parallelize() |
force_new_workflow | bool | Force a new workflow for each invocation |
reroute_on_cc | bool | Reroute when hitting concurrency limits |
blocking | bool | Run on a blocking thread |