pub struct AppState {
pub store: Arc<dyn Store>,
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 store (runs, users, API keys, secrets) 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::store::Store;
use ironflow_engine::engine::Engine;
use ironflow_core::providers::claude::ClaudeCodeProvider;
use std::sync::Arc;
let store: Arc<dyn Store> = 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, engine, jwt_config, "token".to_string(), broadcaster.sender());Fields§
§store: Arc<dyn Store>The unified backing store for runs, steps, users, API keys, and secrets.
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 Store>,
engine: Arc<Engine>,
jwt_config: Arc<JwtConfig>,
worker_token: String,
event_sender: Sender<Event>,
) -> Self
pub fn new( store: Arc<dyn Store>, engine: Arc<Engine>, jwt_config: Arc<JwtConfig>, worker_token: String, event_sender: Sender<Event>, ) -> Self
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