pub struct AppState {
pub auth: AuthLayer,
pub metrics: Arc<Metrics>,
/* private fields */
}Expand description
Shared state for HTTP handlers.
authorizer and audit are private with public accessors
(authorizer(), audit()). The authorizer handle atomically swaps
policy snapshots when the watcher observes a valid change, so in-flight
requests finish against the snapshot they started with.
Fields§
§auth: AuthLayerAuthentication layer. Disabled allows any caller; ApiKey
validates Authorization: Bearer <raw>.
metrics: Arc<Metrics>Metrics registry. Always populated; even with no exporter
wired, /metrics returns the current snapshot.
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn with_audit_appender(self, appender: Arc<dyn AuditAppender>) -> Self
pub fn with_audit_appender(self, appender: Arc<dyn AuditAppender>) -> Self
Replace the configured audit writer with an embedder-provided durable
adapter. Use this with build_state and audit_log: None when audit
persistence is managed outside the local filesystem.
Readiness requires the adapter to report both healthy and chained. Every successful authorization is returned only after the adapter confirms its append; append failures fail closed.
Sourcepub fn with_async_audit_appender(
self,
appender: Arc<dyn AsyncAuditAppender>,
) -> Self
pub fn with_async_audit_appender( self, appender: Arc<dyn AsyncAuditAppender>, ) -> Self
Inject an async durable audit adapter. The per-state PDP work permit remains held until persistence completes, applying bounded backpressure without occupying a Tokio blocking worker during remote I/O.
The authorization engine. Cheap to clone (already an Arc).
Sourcepub fn audit(&self) -> Option<&DecisionLog>
pub fn audit(&self) -> Option<&DecisionLog>
The audit log writer, if configured. None when the operator
disabled audit logging.
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 !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
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>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request