saddle-framework 0.1.0

The single business-facing facade for Saddle applications
Documentation
//! The only Saddle crate that business applications directly depend on.
//!
//! Pool construction and Service registry assembly remain framework-owned:
//!
//! ```compile_fail
//! let _ = saddle::db::Database::connect;
//! ```
//!
//! ```compile_fail
//! let _ = saddle::service::ServiceRegistryBuilder::new();
//! ```

mod application;
pub mod db;
mod http;

pub use application::{Saddle, SaddleBuilder, SaddleConfig};

pub use saddle_core::{
    ApplicationId, CallContext, ErrorKind, ModuleId, OperationId, Result, SaddleError, ServiceId,
    SpanId, TraceId,
};

/// Short business-facing name for Saddle Observability.
pub mod obs {
    pub use saddle_observability::{DomainEvent, DomainEventError, DomainValue, EventLevel};

    use crate::{CallContext, ErrorKind, Result, SaddleError};

    /// Records one bounded domain event on the current Saddle call context.
    pub fn record(context: &CallContext, event: DomainEvent) -> Result<()> {
        let observer = saddle_observability::global().ok_or_else(|| {
            SaddleError::new(
                ErrorKind::Unavailable,
                "observability.not_initialized",
                "Saddle observability is not initialized",
            )
        })?;
        observer.record_domain_event(context, event);
        Ok(())
    }
}

pub mod service {
    pub use saddle_service::{
        Service, ServiceClient, ServiceDescriptor, ServiceFuture, ServiceHandler, ServiceResolver,
    };
}