Skip to main content

TaskDescriptor

Struct TaskDescriptor 

Source
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 each Job at enqueue; if the registered task’s hash changes while a job is still active, dispatch returns BosonError::SignatureMismatch. Bump signature_hash when you change parameter shape incompatibly.

Fields§

§name: &'static str

Unique 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 str

JSON schema string for parameters (documentation / tooling; not validated at runtime).

§signature_hash: u64

Version hash checked against enqueued jobs; change when parameters change incompatibly.

§default_priority: i32

Default priority (lower = higher priority).

§default_pool: &'static str

Default pool name for worker assignment.

§default_retry_max_attempts: u32

Default retry max attempts (see RetryPolicy::max_attempts).

§default_retry_base_delay_ms: u64

Default retry base delay ms (see RetryPolicy::base_delay_ms).

§default_retry_backoff_multiplier: f64

Default retry backoff multiplier (see RetryPolicy::backoff_multiplier).

§default_retry_max_delay_ms: u64

Default retry max delay ms (see RetryPolicy::max_delay_ms).

§default_rate_max_in_flight: u32

Default max in-flight jobs (see RateLimitPolicy::max_in_flight; 0 = unlimited).

§default_rate_max_enqueue_per_second: u32

Default 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

Source

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).

Source

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.

Source

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.

Source

pub fn to_task_config(&self) -> TaskConfig

Materialize descriptor defaults into a TaskConfig.

Trait Implementations§

Source§

impl Clone for TaskDescriptor

Source§

fn clone(&self) -> TaskDescriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Collect for TaskDescriptor

Source§

impl Copy for TaskDescriptor

Source§

impl Debug for TaskDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Registrable for TaskDescriptor

Source§

fn registry_key(&self) -> &str

Return the unique lookup key used by the registry.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more