Skip to main content

saddle/
lib.rs

1//! The only Saddle crate that business applications directly depend on.
2//!
3//! Pool construction and Service registry assembly remain framework-owned:
4//!
5//! ```compile_fail
6//! let _ = saddle::db::Database::connect;
7//! ```
8//!
9//! ```compile_fail
10//! let _ = saddle::service::ServiceRegistryBuilder::new();
11//! ```
12
13mod application;
14pub mod db;
15mod http;
16
17pub use application::{Saddle, SaddleBuilder, SaddleConfig};
18
19pub use saddle_core::{
20    ApplicationId, CallContext, ErrorKind, ModuleId, OperationId, Result, SaddleError, ServiceId,
21    SpanId, TraceId,
22};
23
24/// Short business-facing name for Saddle Observability.
25pub mod obs {
26    pub use saddle_observability::{DomainEvent, DomainEventError, DomainValue, EventLevel};
27
28    use crate::{CallContext, ErrorKind, Result, SaddleError};
29
30    /// Records one bounded domain event on the current Saddle call context.
31    pub fn record(context: &CallContext, event: DomainEvent) -> Result<()> {
32        let observer = saddle_observability::global().ok_or_else(|| {
33            SaddleError::new(
34                ErrorKind::Unavailable,
35                "observability.not_initialized",
36                "Saddle observability is not initialized",
37            )
38        })?;
39        observer.record_domain_event(context, event);
40        Ok(())
41    }
42}
43
44pub mod service {
45    pub use saddle_service::{
46        Service, ServiceClient, ServiceDescriptor, ServiceFuture, ServiceHandler, ServiceResolver,
47    };
48}