taskvisor 0.6.0

Task supervisor for Tokio: restarts background tasks on failure with exponential backoff and jitter, graceful shutdown, and lifecycle events
Documentation
//! # Stable `reason` values
//!
//! Some events and outcomes contain a `reason` text.
//! Only the values and prefixes in this module are stable for machine matching.
//! Other reason text may change between releases.
//!
//! Exact value:
//!
//! ```rust
//! use taskvisor::reasons::ALREADY_EXISTS;
//! assert_eq!("already_exists", ALREADY_EXISTS);
//! ```
//!
//! Prefix with details:
//!
//! ```rust
//! use taskvisor::reasons::MAX_RETRIES_EXCEEDED;
//! let reason = "max_retries_exceeded(3/3): connection lost";
//! assert!(reason.starts_with(MAX_RETRIES_EXCEEDED));
//! ```
//!
//! ## Where each value appears
//!
//! | Constant                     | Used by                                                | Meaning                                |
//! |------------------------------|--------------------------------------------------------|----------------------------------------|
//! | [`POLICY_EXHAUSTED_SUCCESS`] | `ActorExhausted`                                       | Normal one-shot finish.                |
//! | [`TASK_RETURNED_CANCELED`]   | `ActorExhausted`                                       | The task stopped itself.               |
//! | [`MAX_RETRIES_EXCEEDED`]     | `ActorExhausted` (prefix)                              | Retry limit reached.                   |
//! | [`ALREADY_EXISTS`]           | `TaskAddFailed`, `TaskOutcome::Rejected`               | A task with this name already exists.  |
//! | [`BATCH_REJECTED`]           | `TaskAddFailed`                                        | Another item rejected the whole batch. |
//! | [`QUEUE_FULL`]               | `ControllerRejected`, `TaskOutcome::Rejected` (prefix) | The slot queue is full.                |
//! | [`REMOVED_FROM_QUEUE`]       | `ControllerRejected`, `TaskOutcome::Rejected`          | A queued task was removed.             |
//! | [`SUPERSEDED_BY_REPLACE`]    | `ControllerRejected`, `TaskOutcome::Rejected`          | A newer `Replace` task took its place. |
//! | [`CONTROLLER_SHUTTING_DOWN`] | `ControllerRejected`, `TaskOutcome::Rejected`          | The controller is shutting down.       |
//!
//! Controller rejection values are used only with the `controller` feature.
//! The constants themselves are always available.

/// `ActorExhausted` reason: the task finished successfully under a `Never`/`OnFailure` policy.
/// This is not an error.
pub const POLICY_EXHAUSTED_SUCCESS: &str = "policy_exhausted_success";

/// `ActorExhausted` reason: the task body returned [`TaskError::Canceled`](crate::TaskError::Canceled), but the runtime did not cancel it.
/// This is not an error.
pub const TASK_RETURNED_CANCELED: &str = "task_returned_canceled";

/// Registration/rejection reason: another registered task already uses this name.
pub const ALREADY_EXISTS: &str = "already_exists";

/// Registration reason: another item caused an all-or-nothing static batch to be rejected.
pub const BATCH_REJECTED: &str = "batch_rejected";

/// Rejection reason: a queued task was removed before it started.
pub const REMOVED_FROM_QUEUE: &str = "removed_from_queue";

/// Rejection reason: a newer `Replace` task took this task's place.
pub const SUPERSEDED_BY_REPLACE: &str = "superseded_by_replace";

/// Rejection reason: the controller is shutting down.
pub const CONTROLLER_SHUTTING_DOWN: &str = "controller_shutting_down";

/// `ActorExhausted` reason **prefix**: the task stopped after it used all retry attempts.
///
/// The full reason is `max_retries_exceeded(<retries_used>/<retry_limit>): <last error>`.
/// Match with `starts_with`, not equality.
pub const MAX_RETRIES_EXCEEDED: &str = "max_retries_exceeded";

/// Rejection reason **prefix**: a controller slot queue is full.
///
/// The full reason is `queue_full: <depth>/<limit>`.
/// Match with `starts_with`, not equality.
pub const QUEUE_FULL: &str = "queue_full";