etdl_core/lib.rs
1//! Runtime library for code generated from Event Tree Definition Language
2//! (ETDL) documents — the reliability-aware, event-driven DSL based on
3//! [IEC 62502](https://github.com/usamassem/etdl-specification) event tree and
4//! [IEC 61025](https://github.com/usamassem/etdl-specification) fault tree analysis.
5//!
6//! Generated handlers use these components to record branches and failures
7//! against build-time-resolved probabilities, enforce declared retry policies,
8//! detect SLA anomalies, and inject chaos in controlled environments.
9//!
10//! # Components
11//!
12//! - [`BranchMonitor`] — records taken branches and failures per node with their
13//! declared probabilities
14//! - [`RetryPolicy`] / [`BackoffStrategy`] — async retry with exponential or fixed
15//! backoff and a total time budget
16//! - [`SlaTracker`] — rolling-window anomaly detection
17//! (`ETDL_SLA_WINDOW`, `ETDL_SLA_THRESHOLD`)
18//! - [`ChaosController`] — seeded, node-scoped failure injection, guarded off in
19//! production via `ETDL_ENV`
20//! - [`inject_traceparent`] — W3C trace context propagation
21//!
22//! # Example
23//!
24//! ```
25//! use etdl_core::{BranchMonitor, BackoffStrategy, RetryPolicy};
26//! use std::time::Duration;
27//!
28//! let mut monitor = BranchMonitor::new("InventoryCheckBarrier");
29//! monitor.record_branch("SUCCESS", 0.95);
30//!
31//! let retry = RetryPolicy {
32//! max_attempts: 3,
33//! backoff_ms: 250,
34//! strategy: BackoffStrategy::Exponential,
35//! };
36//! ```
37
38pub mod chaos;
39pub mod monitor;
40pub mod retry;
41pub mod sla;
42pub mod telemetry;
43
44pub use monitor::BranchMonitor;
45pub use retry::{BackoffStrategy, RetryPolicy};
46pub use sla::SlaTracker;
47pub use chaos::ChaosController;
48pub use telemetry::{
49 inject_traceparent, Error as WorkflowError,
50};