#[cfg(feature = "sqlite")]
pub mod sqlite {
use async_trait::async_trait;
use atomr_agents_core::{AgentError, Result, RunId, WorkflowId};
use crate::checkpointer::{CheckpointKey, CheckpointMeta, Checkpointer, Snapshot};
pub struct SqliteCheckpointer {
pub url: String,
}
impl SqliteCheckpointer {
pub async fn connect(url: impl Into<String>) -> Result<Self> {
Ok(Self { url: url.into() })
}
}
fn unsupported<T>() -> Result<T> {
Err(AgentError::Internal(
"SqliteCheckpointer: backend stub. Enable the real implementation in your deployment patch."
.into(),
))
}
#[async_trait]
impl Checkpointer for SqliteCheckpointer {
async fn save(&self, _snapshot: Snapshot) -> Result<()> {
unsupported()
}
async fn load(&self, _key: &CheckpointKey) -> Result<Option<Snapshot>> {
unsupported()
}
async fn latest(&self, _workflow_id: &WorkflowId, _run_id: &RunId) -> Result<Option<Snapshot>> {
unsupported()
}
async fn list(&self, _workflow_id: &WorkflowId, _run_id: &RunId) -> Result<Vec<CheckpointMeta>> {
unsupported()
}
async fn fork(
&self,
_from: &CheckpointKey,
_edits: Vec<(String, atomr_agents_core::Value)>,
) -> Result<RunId> {
unsupported()
}
}
}
#[cfg(feature = "postgres")]
pub mod postgres {
use async_trait::async_trait;
use atomr_agents_core::{AgentError, Result, RunId, WorkflowId};
use crate::checkpointer::{CheckpointKey, CheckpointMeta, Checkpointer, Snapshot};
pub struct PostgresCheckpointer {
pub url: String,
}
impl PostgresCheckpointer {
pub async fn connect(url: impl Into<String>) -> Result<Self> {
Ok(Self { url: url.into() })
}
}
fn unsupported<T>() -> Result<T> {
Err(AgentError::Internal(
"PostgresCheckpointer: backend stub. Enable the real implementation in your deployment patch."
.into(),
))
}
#[async_trait]
impl Checkpointer for PostgresCheckpointer {
async fn save(&self, _snapshot: Snapshot) -> Result<()> {
unsupported()
}
async fn load(&self, _key: &CheckpointKey) -> Result<Option<Snapshot>> {
unsupported()
}
async fn latest(&self, _workflow_id: &WorkflowId, _run_id: &RunId) -> Result<Option<Snapshot>> {
unsupported()
}
async fn list(&self, _workflow_id: &WorkflowId, _run_id: &RunId) -> Result<Vec<CheckpointMeta>> {
unsupported()
}
async fn fork(
&self,
_from: &CheckpointKey,
_edits: Vec<(String, atomr_agents_core::Value)>,
) -> Result<RunId> {
unsupported()
}
}
}