pub struct AppState {
pub model_cache: Arc<Mutex<ModelCache>>,
pub engine_snapshot: Arc<RwLock<EngineSnapshot>>,
pub active_generation: Arc<RwLock<Option<ActiveGenerationSnapshot>>>,
pub config: Arc<RwLock<Config>>,
pub start_time: Instant,
pub model_load_lock: Arc<Mutex<()>>,
pub pull_lock: Arc<Mutex<()>>,
pub queue: QueueHandle,
pub shared_pool: Arc<Mutex<SharedPool>>,
pub shutdown_tx: Arc<Mutex<Option<Sender<()>>>>,
}Fields§
§model_cache: Arc<Mutex<ModelCache>>§engine_snapshot: Arc<RwLock<EngineSnapshot>>§active_generation: Arc<RwLock<Option<ActiveGenerationSnapshot>>>Uses std::sync::RwLock (not tokio) because it’s only accessed from synchronous contexts (inside spawn_blocking closures and brief reads). Must never be held across an .await point.
config: Arc<RwLock<Config>>§start_time: Instant§model_load_lock: Arc<Mutex<()>>Guards concurrent model loads and hot-swaps.
pull_lock: Arc<Mutex<()>>Guards concurrent pulls — only one download at a time.
queue: QueueHandleGeneration request queue.
Shared tokenizer pool for cross-engine caching.
shutdown_tx: Arc<Mutex<Option<Sender<()>>>>Shutdown trigger for graceful shutdown via /api/shutdown endpoint.
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(
engine: Box<dyn InferenceEngine>,
config: Config,
queue: QueueHandle,
) -> Self
pub fn new( engine: Box<dyn InferenceEngine>, config: Config, queue: QueueHandle, ) -> Self
Create state with a pre-loaded engine (server starts with a configured model).
Sourcepub fn empty(config: Config, queue: QueueHandle) -> Self
pub fn empty(config: Config, queue: QueueHandle) -> Self
Create state with no engine (zero-config startup, models pulled on demand).
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more