use crate::database::{AnyPool, BackendType, Database};
#[cfg(feature = "postgres")]
pub mod agent_desired;
#[cfg(feature = "postgres")]
pub mod agent_limits;
#[cfg(feature = "postgres")]
pub mod api_keys;
pub mod checkpoint;
pub mod context;
pub mod delivery_outbox;
pub mod execution_event;
pub mod fleet_agents;
#[cfg(feature = "postgres")]
pub mod local_accounts;
pub mod login_throttle;
pub mod models;
#[cfg(feature = "postgres")]
pub mod oidc_login_flows;
#[cfg(feature = "postgres")]
pub mod oidc_sessions;
pub mod reactor_owner_addresses;
pub mod reactor_subscriptions;
pub mod recovery_event;
pub mod schedule;
pub mod schedule_execution;
pub mod task_execution;
pub mod task_execution_metadata;
pub mod workflow_execution;
pub mod workflow_packages;
pub mod workflow_registry_storage;
pub mod ws_tickets;
#[cfg(feature = "postgres")]
pub use agent_desired::AgentDesiredDAL;
#[cfg(feature = "postgres")]
pub use agent_limits::AgentLimitsDAL;
#[cfg(feature = "postgres")]
pub use api_keys::{ApiKeyDAL, ApiKeyInfo};
pub use checkpoint::CheckpointDAL;
pub use context::ContextDAL;
pub use delivery_outbox::DeliveryOutboxDAL;
pub use execution_event::ExecutionEventDAL;
pub use fleet_agents::{FleetAgent, FleetAgentDAL, FleetAgentRegistration};
#[cfg(feature = "postgres")]
pub use local_accounts::{LocalAccount, LocalAccountDAL, LoginOutcome};
pub use login_throttle::{LoginThrottleDAL, ThrottlePolicy, ThrottleState};
#[cfg(feature = "postgres")]
pub use oidc_login_flows::OidcLoginFlowDAL;
#[cfg(feature = "postgres")]
pub use oidc_sessions::{OidcSessionDAL, RefreshSession};
pub use reactor_subscriptions::{
compile_predicate, lint_predicate_variables, truncate_predicate_text, ReactorFiring,
ReactorSubscription, ReactorSubscriptionsDAL, PREDICATE_VARIABLES,
};
pub use recovery_event::RecoveryEventDAL;
pub use schedule::ScheduleDAL;
pub use schedule_execution::{
RecoveryClaimResult, RecoveryHeartbeatResult, ScheduleExecutionDAL, ScheduleExecutionStats,
};
pub use task_execution::{RetryStats, TaskExecutionDAL};
pub use task_execution_metadata::TaskExecutionMetadataDAL;
pub use workflow_execution::WorkflowExecutionDAL;
pub use workflow_packages::WorkflowPackagesDAL;
pub use workflow_registry_storage::UnifiedRegistryStorage;
pub use ws_tickets::{WsTicketAuth, WsTicketDAL};
#[derive(Clone, Debug)]
pub struct DAL {
pub database: Database,
}
impl DAL {
pub fn new(database: Database) -> Self {
DAL { database }
}
pub fn backend(&self) -> BackendType {
self.database.backend()
}
pub fn database(&self) -> &Database {
&self.database
}
pub fn pool(&self) -> AnyPool {
self.database.pool()
}
#[cfg(feature = "postgres")]
pub fn agent_limits(&self) -> AgentLimitsDAL<'_> {
AgentLimitsDAL::new(self)
}
#[cfg(feature = "postgres")]
pub fn agent_desired(&self) -> AgentDesiredDAL<'_> {
AgentDesiredDAL::new(self)
}
#[cfg(feature = "postgres")]
pub fn api_keys(&self) -> ApiKeyDAL<'_> {
ApiKeyDAL::new(self)
}
#[cfg(feature = "postgres")]
pub fn oidc_sessions(&self) -> OidcSessionDAL<'_> {
OidcSessionDAL::new(self)
}
#[cfg(feature = "postgres")]
pub fn local_accounts(&self) -> LocalAccountDAL<'_> {
LocalAccountDAL::new(self)
}
pub fn login_throttle(&self) -> LoginThrottleDAL<'_> {
LoginThrottleDAL::new(self)
}
pub fn reactor_owner_addresses(&self) -> reactor_owner_addresses::ReactorOwnerAddressesDAL<'_> {
reactor_owner_addresses::ReactorOwnerAddressesDAL::new(self)
}
#[cfg(feature = "postgres")]
pub fn oidc_login_flows(&self) -> OidcLoginFlowDAL<'_> {
OidcLoginFlowDAL::new(self)
}
pub fn checkpoint(&self) -> CheckpointDAL<'_> {
CheckpointDAL::new(self)
}
pub fn context(&self) -> ContextDAL<'_> {
ContextDAL::new(self)
}
pub fn workflow_execution(&self) -> WorkflowExecutionDAL<'_> {
WorkflowExecutionDAL::new(self)
}
pub fn task_execution(&self) -> TaskExecutionDAL<'_> {
TaskExecutionDAL::new(self)
}
pub fn task_execution_metadata(&self) -> TaskExecutionMetadataDAL<'_> {
TaskExecutionMetadataDAL::new(self)
}
pub fn delivery_outbox(&self) -> DeliveryOutboxDAL<'_> {
DeliveryOutboxDAL::new(self)
}
pub fn fleet_agents(&self) -> FleetAgentDAL<'_> {
FleetAgentDAL::new(self)
}
pub fn ws_tickets(&self) -> WsTicketDAL<'_> {
WsTicketDAL::new(self)
}
pub fn recovery_event(&self) -> RecoveryEventDAL<'_> {
RecoveryEventDAL::new(self)
}
pub fn execution_event(&self) -> ExecutionEventDAL<'_> {
ExecutionEventDAL::new(self)
}
pub fn schedule(&self) -> ScheduleDAL<'_> {
ScheduleDAL::new(self)
}
pub fn schedule_execution(&self) -> ScheduleExecutionDAL<'_> {
ScheduleExecutionDAL::new(self)
}
pub fn workflow_packages(&self) -> WorkflowPackagesDAL<'_> {
WorkflowPackagesDAL::new(self)
}
pub fn reactor_subscriptions(&self) -> ReactorSubscriptionsDAL<'_> {
ReactorSubscriptionsDAL::new(self)
}
pub fn workflow_registry<S: crate::registry::traits::RegistryStorage + 'static>(
&self,
storage: S,
) -> crate::registry::workflow_registry::WorkflowRegistryImpl<S> {
self.try_workflow_registry(storage)
.expect("Failed to create workflow registry")
}
pub fn try_workflow_registry<S: crate::registry::traits::RegistryStorage + 'static>(
&self,
storage: S,
) -> Result<
crate::registry::workflow_registry::WorkflowRegistryImpl<S>,
crate::registry::error::RegistryError,
> {
crate::registry::workflow_registry::WorkflowRegistryImpl::new(
storage,
self.database.clone(),
)
}
}