ironflow_worker/lib.rs
1//! # ironflow-worker
2//!
3//! HTTP-based background worker for ironflow. Polls the API server for
4//! pending workflow runs, executes them locally, and reports results back.
5//!
6//! The worker communicates with the API via `/api/v1/internal/*` routes,
7//! authenticated with a static `WORKER_TOKEN`.
8//!
9//! With the `prometheus` feature, `WorkerBuilder::metrics_addr` serves the worker
10//! metrics in the Prometheus text format on `GET /metrics`. The library does not
11//! read any environment variable: the address comes from the caller.
12//!
13//! # Quick start
14//!
15//! ```no_run
16//! use std::sync::Arc;
17//! use std::time::Duration;
18//! use ironflow_worker::WorkerBuilder;
19//! use ironflow_core::providers::claude::ClaudeCodeProvider;
20//!
21//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
22//! let worker = WorkerBuilder::new("http://localhost:3000", "my-worker-token")
23//! .provider(Arc::new(ClaudeCodeProvider::new()))
24//! .concurrency(4)
25//! .poll_interval(Duration::from_secs(2))
26//! .build()?;
27//!
28//! worker.run().await?;
29//! # Ok(())
30//! # }
31//! ```
32
33pub mod api_store;
34mod artifact_sink;
35pub mod error;
36mod log_pusher;
37#[cfg(feature = "prometheus")]
38mod queue_depth;
39pub mod worker;
40
41pub use api_store::ApiRunStore;
42pub use error::WorkerError;
43pub use worker::{Worker, WorkerBuilder};