pub struct AppState {
pub store: Arc<dyn RunStore>,
pub user_store: Arc<dyn UserStore>,
pub engine: Arc<Engine>,
pub jwt_config: Arc<JwtConfig>,
pub worker_token: String,
}Expand description
Global application state.
Holds the shared run store and engine, extracted by handlers using Axum’s state extraction mechanism.
§Examples
use ironflow_api::state::AppState;
use ironflow_auth::jwt::JwtConfig;
use ironflow_store::prelude::*;
use ironflow_engine::engine::Engine;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use std::sync::Arc;
let store = Arc::new(InMemoryStore::new());
let user_store: Arc<dyn UserStore> = Arc::new(InMemoryStore::new());
let provider = Arc::new(ClaudeCodeProvider::new());
let engine = Arc::new(Engine::new(store.clone(), provider));
let jwt_config = Arc::new(JwtConfig {
secret: "secret".to_string(),
access_token_ttl_secs: 900,
refresh_token_ttl_secs: 604800,
cookie_domain: None,
cookie_secure: false,
});
let state = AppState::new(store, user_store, engine, jwt_config, "token".to_string());Fields§
§store: Arc<dyn RunStore>The backing store for runs and steps.
user_store: Arc<dyn UserStore>The backing store for users.
engine: Arc<Engine>The workflow orchestration engine.
jwt_config: Arc<JwtConfig>JWT configuration for auth tokens.
worker_token: StringStatic token for worker-to-API authentication.
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(
store: Arc<dyn RunStore>,
user_store: Arc<dyn UserStore>,
engine: Arc<Engine>,
jwt_config: Arc<JwtConfig>,
worker_token: String,
) -> Self
pub fn new( store: Arc<dyn RunStore>, user_store: Arc<dyn UserStore>, engine: Arc<Engine>, jwt_config: Arc<JwtConfig>, worker_token: String, ) -> Self
Fetch a run by ID or return 404.
§Errors
Returns ApiError::RunNotFound if the run does not exist.
Returns ApiError::Store if there is a store error.
Create a new AppState.
When the prometheus feature is enabled, a global Prometheus recorder
is installed (once) and its handle is stored in the state.
§Panics
Panics if a Prometheus recorder cannot be installed (should only happen if another incompatible recorder was set elsewhere).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppState
impl !RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl !UnwindSafe for AppState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more