pub struct AppState<C> { /* private fields */ }Expand description
State cloned into every RDF4J / Waratah HTTP handler.
Cloning an AppState must stay O(1): axum clones it once per request, and
a deep clone here puts dozens of allocations on the hot path (the compute
node, router rings, repository catalog, warning list). That churn was
measurable — enough allocator warm-up to make a fresh process’s first query
executions visibly slower than the same process’s steady state — so every
process-lifetime service lives once behind the single Arc, and requests
borrow through it. Add fields to [AppStateInner], never to AppState.
The builders clone-on-write via Arc::make_mut: calling one on a state
that was already cloned (and shared with a router) forks the inner state,
so build configuration before the state is shared.
Implementations§
Source§impl<C> AppState<C>
impl<C> AppState<C>
Sourcepub fn new(compute: C) -> Selfwhere
C: ComputeBackend,
pub fn new(compute: C) -> Selfwhere
C: ComputeBackend,
Build state over compute with the default "main" catalog.
Sourcepub fn with_catalog(compute: C, repos: RepositoryCatalog) -> Self
pub fn with_catalog(compute: C, repos: RepositoryCatalog) -> Self
Build state with an explicit catalog (tests / future multi-repo).
Source§impl<C: Clone> AppState<C>
Builders clone-on-write the inner state (Arc::make_mut), so they must
run while the state is unshared — at startup, before the router clones it.
This is the same C: Clone requirement the deep-clone AppState had.
impl<C: Clone> AppState<C>
Builders clone-on-write the inner state (Arc::make_mut), so they must
run while the state is unshared — at startup, before the router clones it.
This is the same C: Clone requirement the deep-clone AppState had.
Sourcepub fn with_warm_state(self, warm: Option<Arc<WarmState>>) -> Self
pub fn with_warm_state(self, warm: Option<Arc<WarmState>>) -> Self
Gate /health on the startup cache-warm tracker.
Sourcepub fn with_startup_warnings(self, warnings: Vec<String>) -> Self
pub fn with_startup_warnings(self, warnings: Vec<String>) -> Self
Surface orchestrator warnings in the /health body.
Sourcepub fn with_ingest_dir(self, dir: PathBuf) -> Self
pub fn with_ingest_dir(self, dir: PathBuf) -> Self
Enable the /waratah/.../ingest API over dir.
Sourcepub fn with_queries_dir(self, dir: PathBuf) -> Self
pub fn with_queries_dir(self, dir: PathBuf) -> Self
Serve GET /waratah/.../queries from {dir}/{repository}/*.rq.
Sourcepub fn with_inline_queries(self, queries: Vec<ServerQuery>) -> Self
pub fn with_inline_queries(self, queries: Vec<ServerQuery>) -> Self
Publish fixed inline queries (the --load-demo samples) for every
known repository, in the given order.
Sourcepub fn with_notebooks(self, state: Arc<NotebookState>) -> Self
pub fn with_notebooks(self, state: Arc<NotebookState>) -> Self
Mount the /jupyter reverse proxy and the notebook capability
endpoints over state.
Sourcepub fn with_ai(self, service: Arc<AiService>) -> Self
pub fn with_ai(self, service: Arc<AiService>) -> Self
Enable the AI routes (discovery, egress proxy, ai-context) over the resolved service state.
Sourcepub fn with_debug(self, enabled: bool) -> Self
pub fn with_debug(self, enabled: bool) -> Self
Enable or disable SPARQL debug logging on stderr.
Sourcepub fn with_query_debug(self, debug: QueryDebug) -> Self
pub fn with_query_debug(self, debug: QueryDebug) -> Self
Install an explicit SPARQL debug logger (shared query-id sequence).
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for AppState<C>
impl<C> !RefUnwindSafe for AppState<C>
impl<C> Send for AppState<C>
impl<C> Sync for AppState<C>
impl<C> Unpin for AppState<C>
impl<C> UnsafeUnpin for AppState<C>
impl<C> !UnwindSafe for AppState<C>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].