pub struct TaskDescriptor {Show 13 fields
pub name: &'static str,
pub invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>,
pub signature_json: &'static str,
pub signature_hash: u64,
pub default_priority: i32,
pub default_pool: &'static str,
pub default_retry_max_attempts: u32,
pub default_retry_base_delay_ms: u64,
pub default_retry_backoff_multiplier: f64,
pub default_retry_max_delay_ms: u64,
pub default_rate_max_in_flight: u32,
pub default_rate_max_enqueue_per_second: u32,
pub default_idempotency_mode: Option<IdempotencyMode>,
}Expand description
Descriptor for a registered task.
Registration defaults flow into TaskConfig on first enqueue.
Use TaskDescriptor::with_defaults to set retry, rate, priority, and pool in one call.
§Signature versioning
signature_json— JSON schema string describing task parameters (convention for tooling; Boson does not validate against it at runtime).signature_hash— hash of the parameter schema/version. Stored on eachJobat enqueue; if the registered task’s hash changes while a job is still active, dispatch returnsBosonError::SignatureMismatch. Bumpsignature_hashwhen you change parameter shape incompatibly.
Fields§
§name: &'static strUnique task name (registry key and enqueue target).
invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>Function to invoke the task.
signature_json: &'static strJSON schema string for parameters (documentation / tooling; not validated at runtime).
signature_hash: u64Version hash checked against enqueued jobs; change when parameters change incompatibly.
default_priority: i32Default priority (lower = higher priority).
default_pool: &'static strDefault pool name for worker assignment.
default_retry_max_attempts: u32Default retry max attempts (see RetryPolicy::max_attempts).
default_retry_base_delay_ms: u64Default retry base delay ms (see RetryPolicy::base_delay_ms).
default_retry_backoff_multiplier: f64Default retry backoff multiplier (see RetryPolicy::backoff_multiplier).
default_retry_max_delay_ms: u64Default retry max delay ms (see RetryPolicy::max_delay_ms).
default_rate_max_in_flight: u32Default max in-flight jobs (see RateLimitPolicy::max_in_flight; 0 = unlimited).
default_rate_max_enqueue_per_second: u32Default max enqueues per second (see RateLimitPolicy::max_enqueue_per_second; 0 = unlimited).
default_idempotency_mode: Option<IdempotencyMode>Per-task idempotency override (None = inherit runtime default).
Implementations§
Source§impl TaskDescriptor
impl TaskDescriptor
Sourcepub const fn new(
name: &'static str,
invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>,
) -> TaskDescriptor
pub const fn new( name: &'static str, invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>, ) -> TaskDescriptor
Minimal descriptor for tests (signature_json "{}", signature_hash 0).
Sourcepub const fn with_defaults(
name: &'static str,
invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>,
signature_json: &'static str,
signature_hash: u64,
defaults: TaskDefaults,
) -> TaskDescriptor
pub const fn with_defaults( name: &'static str, invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>, signature_json: &'static str, signature_hash: u64, defaults: TaskDefaults, ) -> TaskDescriptor
Descriptor with grouped policy defaults.
Sourcepub const fn with_policy(
name: &'static str,
invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>,
signature_json: &'static str,
signature_hash: u64,
priority: i32,
pool: &'static str,
max_attempts: u32,
base_delay_ms: u64,
backoff_multiplier: f64,
max_delay_ms: u64,
max_in_flight: u32,
max_enqueue_per_second: u32,
idempotency_mode: Option<IdempotencyMode>,
) -> TaskDescriptor
pub const fn with_policy( name: &'static str, invoke: fn(Box<dyn ExecutionContext>, Value) -> Pin<Box<dyn Future<Output = Result<(), BosonError>> + Send>>, signature_json: &'static str, signature_hash: u64, priority: i32, pool: &'static str, max_attempts: u32, base_delay_ms: u64, backoff_multiplier: f64, max_delay_ms: u64, max_in_flight: u32, max_enqueue_per_second: u32, idempotency_mode: Option<IdempotencyMode>, ) -> TaskDescriptor
Descriptor with explicit per-field policy defaults.
Used by the #[task] attribute when policy fields are set on the handler.
Prefer Self::with_defaults for manual registration in tests.
Sourcepub fn to_task_config(&self) -> TaskConfig
pub fn to_task_config(&self) -> TaskConfig
Materialize descriptor defaults into a TaskConfig.
Trait Implementations§
Source§impl Clone for TaskDescriptor
impl Clone for TaskDescriptor
Source§fn clone(&self) -> TaskDescriptor
fn clone(&self) -> TaskDescriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Collect for TaskDescriptor
impl Copy for TaskDescriptor
Source§impl Debug for TaskDescriptor
impl Debug for TaskDescriptor
Source§impl Registrable for TaskDescriptor
impl Registrable for TaskDescriptor
Source§fn registry_key(&self) -> &str
fn registry_key(&self) -> &str
Auto Trait Implementations§
impl Freeze for TaskDescriptor
impl RefUnwindSafe for TaskDescriptor
impl Send for TaskDescriptor
impl Sync for TaskDescriptor
impl Unpin for TaskDescriptor
impl UnsafeUnpin for TaskDescriptor
impl UnwindSafe for TaskDescriptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more