pub struct AppState {
pub store: Arc<dyn RunStore>,
pub user_store: Arc<dyn UserStore>,
pub api_key_store: Arc<dyn ApiKeyStore>,
pub engine: Arc<Engine>,
pub jwt_config: Arc<JwtConfig>,
pub worker_token: String,
pub event_sender: Sender<Event>,
}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_store::api_key_store::ApiKeyStore;
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 api_key_store: Arc<dyn ApiKeyStore> = 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 broadcaster = ironflow_api::sse::SseBroadcaster::new();
let state = AppState::new(store, user_store, api_key_store, engine, jwt_config, "token".to_string(), broadcaster.sender());Fields§
§store: Arc<dyn RunStore>The backing store for runs and steps.
user_store: Arc<dyn UserStore>The backing store for users.
api_key_store: Arc<dyn ApiKeyStore>The backing store for API keys.
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.
event_sender: Sender<Event>Broadcast sender for SSE event streaming.
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(
store: Arc<dyn RunStore>,
user_store: Arc<dyn UserStore>,
api_key_store: Arc<dyn ApiKeyStore>,
engine: Arc<Engine>,
jwt_config: Arc<JwtConfig>,
worker_token: String,
event_sender: Sender<Event>,
) -> Self
pub fn new( store: Arc<dyn RunStore>, user_store: Arc<dyn UserStore>, api_key_store: Arc<dyn ApiKeyStore>, engine: Arc<Engine>, jwt_config: Arc<JwtConfig>, worker_token: String, event_sender: Sender<Event>, ) -> 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).