use std::error::Error;
use async_trait::async_trait;
mod config;
mod lease;
mod outbox;
mod runner;
pub use config::{BackoffConfig, RetryBackoff, WorkerConfig, WorkerConfigError, WorkerLeaseConfig};
#[cfg(feature = "settings")]
pub use config::{BackoffSettings, WorkerLeaseSettings, WorkerSettings};
pub use lease::{
LocalWorkerLeaseStore, WorkerLease, WorkerLeaseDecision, WorkerLeaseError, WorkerLeaseStore,
};
#[cfg(feature = "settings")]
pub use outbox::OutboxWorkerSettings;
pub use outbox::{
BatchRunSummary, BatchWorker, BatchWorkerJob, OutboxClaim, OutboxFailureClass, OutboxHandler,
OutboxItem, OutboxItemState, OutboxJob, OutboxRetryPolicy, OutboxStore, OutboxWorkerConfig,
};
pub use runner::{
ShutdownToken, ShutdownTrigger, WorkerRunError, WorkerRunOptions, WorkerRunState,
WorkerRunSummary, WorkerTick, WorkerTickOutcome, run_worker_until_shutdown,
run_worker_until_shutdown_with_metrics, run_worker_until_shutdown_with_options,
shutdown_channel,
};
pub type BoxWorkerError = Box<dyn Error + Send + Sync + 'static>;
pub const MAX_WORKER_NAME_LENGTH: usize = 128;
pub const MAX_WORKER_LEASE_OWNER_LENGTH: usize = 128;
#[async_trait]
pub trait Worker: Send + Sync + 'static {
fn name(&self) -> &str;
async fn run_once(&self) -> Result<WorkerTick, BoxWorkerError>;
}
#[cfg(test)]
use runner::ensure_worker_lease;
#[cfg(test)]
mod tests;