pub mod config;
mod offload;
pub mod session;
pub mod state;
use std::sync::Arc;
use anyhow::{Context, Result};
use crate::engine::host::{SessionHost, StateHost};
pub use config::{
DEFAULT_WAIT_TTL, SessionBackend, StateBackend, StorageConfig, StorageConfigError,
};
pub use session::DynSessionStore;
pub use state::DynStateStore;
pub fn new_session_store() -> DynSessionStore {
session::new_session_store()
}
pub fn new_state_store() -> DynStateStore {
state::new_state_store()
}
pub fn session_store_from_config(backend: &SessionBackend) -> Result<DynSessionStore> {
session::store_from_config(backend)
}
pub fn state_store_from_config(backend: &StateBackend) -> Result<DynStateStore> {
state::store_from_config(backend)
}
pub fn stores_from_config(config: &StorageConfig) -> Result<(DynSessionStore, DynStateStore)> {
let session = session_store_from_config(&config.session)
.context("failed to build the runner session store")?;
let state =
state_store_from_config(&config.state).context("failed to build the runner state store")?;
Ok((session, state))
}
pub fn session_host_from(store: DynSessionStore) -> Arc<dyn SessionHost> {
session::session_host_from(store)
}
pub fn state_host_from(store: DynStateStore) -> Arc<dyn StateHost> {
state::state_host_from(store)
}