1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! # Task abstractions.
//!
//! This module contains the types used to define work and describe how it runs.
//!
//! | Type | Role |
//! |-------------------|-----------------------------------------------------|
//! | [`Task`] | Trait for user work |
//! | [`TaskFn`] | Closure-based [`Task`] |
//! | [`TaskRef`] | Shared task handle: `Arc<dyn Task>` |
//! | [`TaskSpec`] | Run config: restart, backoff, timeout, retry limit |
//! | [`BoxTaskFuture`] | Future returned by [`Task::spawn`] |
//!
//! ## Creating A Task
//!
//! - Use [`TaskFn`] for most tasks. Pass a name and an async closure.
//! - Use `impl Task` when the task needs its own type or shared dependencies.
//!
//! ## Data Flow
//!
//! Both paths create a [`TaskRef`]. Wrap it in a [`TaskSpec`] to choose restart policy, backoff, timeout, and retry limit.
//!
//! ```text
//! TaskFn::arc(name, closure) ─┐
//! ├──► TaskRef ──► TaskSpec ──► Supervisor
//! impl Task ─┘
//! ```
//!
//! ## Quick Start
//!
//! ```rust
//! use taskvisor::{TaskContext, TaskError, TaskFn, TaskRef, TaskSpec};
//!
//! let task: TaskRef = TaskFn::arc("worker", |_ctx| async move {
//! Ok(())
//! });
//!
//! let once = TaskSpec::once(task.clone());
//! let restartable = TaskSpec::restartable(task.clone());
//! ```
//!
//! Use [`SupervisorConfig::task_spec`](crate::SupervisorConfig::task_spec) when you want a task to inherit supervisor defaults.
pub use ;
pub use TaskContext;
pub use r#