1#![deny(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
11#![cfg_attr(
12 not(test),
13 deny(
14 clippy::unwrap_used,
15 clippy::unreachable,
16 clippy::expect_used,
17 clippy::panic,
18 clippy::unimplemented,
19 clippy::todo
20 )
21)]
22
23#[cfg(feature = "runtime-component")]
24mod component;
25mod dedupe;
26mod dispatch;
27mod error;
28mod execution;
29mod heartbeat;
30mod lease;
31mod registry;
32mod retry;
33#[cfg(feature = "runtime")]
34mod runtime;
35mod runtime_metadata;
36#[cfg(feature = "runtime")]
37mod schedule;
38mod spec;
39mod steps;
40mod temp;
41
42pub const BACKGROUND_TASKS_COMPONENT: &str = "background_tasks";
44
45#[cfg(feature = "runtime-component")]
46pub use component::{
47 BACKGROUND_TASKS_SHUTDOWN_PHASE, BackgroundTaskRuntimeComponent,
48 BackgroundTaskRuntimeComponentFromShutdown, BackgroundTaskRuntimeDefinitionsComponent,
49 BackgroundTaskRuntimeDefinitionsComponentFromShutdown, background_task_component,
50 background_task_component_from_shutdown, background_task_component_with_definitions,
51 background_task_component_with_definitions_from_shutdown,
52};
53pub use dedupe::{TASK_DEDUPE_KEY_MAX_LEN, TaskDedupeKey, scheduled_task_dedupe_key};
54pub use dispatch::{
55 ClaimableTaskRecord, ClaimedTask, DispatchStats, TaskClaimCandidate, TaskClaimStore,
56 TaskDispatchOutcome, TaskLaneConfig, available_lane_capacity, claim_due_for_lane,
57 claim_limit_to_u64, dispatch_lanes, drain_dispatcher, run_claimed_task_batch,
58 run_with_concurrency_limit,
59};
60pub use error::{Result, TaskCoreError};
61pub use execution::{
62 ClaimedTaskExecutionConfig, ClaimedTaskExecutionStore, ExecutableTaskRecord,
63 TaskPermanentFailure, TaskRetryUpdate, boxed_task_future, process_claimed_task,
64 run_claimed_task_batch_with_store,
65};
66pub use heartbeat::{
67 TaskHeartbeatStore, evaluate_heartbeat_result, run_task_heartbeat_loop,
68 spawn_task_heartbeat_with_interval, stop_task_heartbeat,
69};
70pub use lease::{
71 TaskExecutionContext, TaskLease, TaskLeaseGuard, task_lease_expires_at,
72 task_lease_renewal_timeout,
73};
74pub use registry::TaskRecord;
75pub use retry::{TaskRetryClass, default_task_retry_delay_secs};
76#[cfg(feature = "runtime")]
77pub use runtime::{
78 BACKGROUND_TASK_DISPATCH_ERROR_BACKOFF_CAP, BACKGROUND_TASK_SHUTDOWN_GRACE,
79 BackgroundTaskDispatchBackoff, BackgroundTaskDispatchIteration, BackgroundTaskDispatchTrigger,
80 BackgroundTasks, PeriodicTask, RecordedTaskHooks, effective_dispatch_base_interval,
81 effective_dispatch_max_interval, effective_jitter_cap, periodic_sleep_duration,
82 run_dispatch_worker, run_leased_background_tasks, run_periodic_task,
83 run_recorded_task_iteration,
84};
85pub use runtime_metadata::{RegisteredRuntimeTaskKind, RuntimeTaskDefinition, RuntimeTaskName};
86#[cfg(feature = "runtime")]
87pub use schedule::{
88 LeasedScheduledRuntimeConfig, ScheduledPeriodicTask, ScheduledRuntimeTaskGroup,
89 ScheduledTaskCatalogEntry, ScheduledTaskClaim, ScheduledTaskClaimRenewal,
90 ScheduledTaskClaimRequest, ScheduledTaskCompletion, ScheduledTaskStore, next_scheduled_run_at,
91 run_scheduled_claim_renewal_loop, run_scheduled_periodic_task, scheduled_claim_renew_interval,
92};
93pub use spec::{
94 BackgroundTaskSpec, ErasedBackgroundTaskSpec, TaskProcessFuture, TaskSpecAdapter,
95 decode_payload_as, decode_result_as, serialize_payload, serialize_result,
96};
97pub use steps::{
98 TaskStepInfo, TaskStepSpec, TaskStepStatus, initial_task_steps_from_specs,
99 mark_active_step_failed, set_task_step_active, set_task_step_skipped, set_task_step_succeeded,
100};
101pub use temp::{
102 cleanup_runtime_temp_root, cleanup_task_temp_dir_for_lease_in_root,
103 cleanup_task_temp_dir_for_task_in_root, cleanup_temp_dir, prepare_task_temp_dir_in_root,
104};