pub struct TaskConfig {
pub task_name: String,
pub priority: i32,
pub pool: String,
pub retry_policy: RetryPolicy,
pub rate_limit_policy: RateLimitPolicy,
pub idempotency_mode: Option<IdempotencyMode>,
pub updated_at: DateTime<Utc>,
}Expand description
Per-task config persisted for admin UI and enqueue defaults.
Seeded from task macro attributes on first enqueue; admins can
later upsert via QueueBackend::upsert_task_config
or the axum /tasks/{name}/config route. On enqueue, Boson merges descriptor defaults with any
stored config to set Job priority, pool, and policies.
Getting started: define tasks.
§Example — macro attrs become the initial config
use boson::task;
#[task(
name = "notify",
priority = 10,
pool = "alerts",
max_attempts = 5,
max_in_flight = 20
)]
async fn notify(ctx: Box<dyn boson::ExecutionContext>, message: String) -> boson_core::Result<()> {
let _ = (ctx, message);
Ok(())
}
// First Notify::send_with(...) persists a TaskConfig shaped like those attributes.Fields§
§task_name: StringTask name (unique key).
priority: i32Override priority (lower = higher priority).
pool: StringOverride pool name.
retry_policy: RetryPolicyRetry policy override.
rate_limit_policy: RateLimitPolicyEnqueue rate limits (optional).
idempotency_mode: Option<IdempotencyMode>Per-task idempotency override (None = inherit runtime / builder default).
updated_at: DateTime<Utc>When created/updated.
Implementations§
Source§impl TaskConfig
impl TaskConfig
Sourcepub fn default_for(task_name: &str) -> TaskConfig
pub fn default_for(task_name: &str) -> TaskConfig
Create default config for a task name.
§Examples
use boson_core::TaskConfig;
let config = TaskConfig::default_for("notify");
assert_eq!(config.task_name, "notify");
assert_eq!(config.pool, "global");
assert_eq!(config.priority, 1);Sourcepub fn resolved_idempotency_mode(
&self,
runtime_default: IdempotencyMode,
) -> IdempotencyMode
pub fn resolved_idempotency_mode( &self, runtime_default: IdempotencyMode, ) -> IdempotencyMode
Resolve effective idempotency mode (task override, else runtime_default).
Sourcepub fn from_policy_defaults(
task_name: &str,
priority: i32,
pool: impl Into<String>,
retry_policy: RetryPolicy,
rate_limit_policy: RateLimitPolicy,
idempotency_mode: Option<IdempotencyMode>,
) -> TaskConfig
pub fn from_policy_defaults( task_name: &str, priority: i32, pool: impl Into<String>, retry_policy: RetryPolicy, rate_limit_policy: RateLimitPolicy, idempotency_mode: Option<IdempotencyMode>, ) -> TaskConfig
Build config from explicit policy defaults (typically from a task descriptor).
Sourcepub const fn with_runtime_idempotency_fallback(
self,
runtime_default: IdempotencyMode,
) -> TaskConfig
pub const fn with_runtime_idempotency_fallback( self, runtime_default: IdempotencyMode, ) -> TaskConfig
Fill idempotency_mode from the runtime default when unset.
Trait Implementations§
Source§impl Clone for TaskConfig
impl Clone for TaskConfig
Source§fn clone(&self) -> TaskConfig
fn clone(&self) -> TaskConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TaskConfig
impl Debug for TaskConfig
Source§impl<'de> Deserialize<'de> for TaskConfig
impl<'de> Deserialize<'de> for TaskConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TaskConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TaskConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for TaskConfig
impl Serialize for TaskConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for TaskConfig
impl RefUnwindSafe for TaskConfig
impl Send for TaskConfig
impl Sync for TaskConfig
impl Unpin for TaskConfig
impl UnsafeUnpin for TaskConfig
impl UnwindSafe for TaskConfig
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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