Consumer

Struct Consumer 

Source
pub struct Consumer {
    pub name: String,
    pub credentials: Vec<Credential>,
    pub policies: Vec<String>,
    pub consumer_type: ConsumerType,
    pub tool_allowlist: Vec<String>,
    pub token_budget: Option<TokenBudget>,
    pub priority: Option<u8>,
    pub groups: Vec<String>,
    pub authorization: Option<Authz>,
    pub quotas: Option<ConsumerQuotas>,
    pub ai_logging: Option<bool>,
    pub agent: Option<AgentPrincipal>,
}
Expand description

Identity of an API caller (app/team/user); owns credentials, quotas, and the analytics identity.

Fields§

§name: String§credentials: Vec<Credential>§policies: Vec<String>§consumer_type: ConsumerType

The principal kind (DW-113): user (default) or agent. Agent consumers gain a tool allowlist, a per-agent token budget, and typed analytics attribution. The field is renamed to type in YAML (type is a Rust keyword).

§tool_allowlist: Vec<String>

MCP tool allowlist (DW-113): when non-empty, the consumer may only call the named tools through the MCP gateway. Empty (the default) = no restriction. Validation checks that every name references a configured ai.mcp.tools entry.

§token_budget: Option<TokenBudget>

Per-agent AI token budget (DW-113): when set, this consumer’s AI traffic is bounded by this budget BEFORE the policy chain (the most-specific budget). Same shape as a policy’s token_budget. None (the default) = no per-agent budget; the policy chain governs as before.

§priority: Option<u8>

Consumer priority class for load shedding (DW-016): 0 (lowest) to 10 (highest). Stored and validated now; it takes effect only once authentication (DW-019/DW-020) identifies the consumer on a request — until then, shedding priority comes from the matched route (or the default 5). Consumer priority overrides the route’s when known, but it does NOT trigger reserved-bucket carving today — only a high-priority route does.

§groups: Vec<String>

Consumer group memberships (DW-020): group names this consumer belongs to, consulted by authorization allowed_groups / denied_groups rules. Empty (the default) = no groups. Group names are free-form strings; validation checks that authorization rules referencing groups resolve against at least one consumer’s membership. Store-managed consumers carry their own groups in the state store (#124) — the group NAMESPACE is shared, but config-time validation can only see config consumers, so a rule referencing a group that exists solely on store consumers is flagged (grant at least one config consumer the same group name, or accept the issue is a false positive for store-only groups).

§authorization: Option<Authz>

Consumer-level authorization rules (#123): the MOST specific link of the frozen chain consumer > route > service > listener > global — applies to every request authenticated as this consumer (naturally only once authentication has identified it). A deny at any level wins; otherwise the most specific level with rules governs (see Authz and the authz module). Same validation rules as route-level authorization.

§quotas: Option<ConsumerQuotas>

Request budgets for this consumer (DW-033): a daily and/or monthly request cap counted in fixed UTC calendar windows (midnight-to-midnight UTC; the first through the last instant of the UTC month). Budgets are DISTINCT from rate limits: a rate limit shapes traffic inside seconds or minutes, a budget bounds total volume across a day or month, and the two mechanisms run independently (both apply when both are configured). Enforcement needs the state store (DWARA_STATE_DB) for durable counters — without one, quota config is inert (logged at request time, see the state::quotas module docs). Store-managed consumers have no config record, so budgets are config-consumer-only in this edition; a distributed shared-counter variant is the Ent follow-up (issue “DW-155”).

§ai_logging: Option<bool>

AI prompt/response logging override (DW-081). None = inherit the global ai.logging.enabled setting; Some(false) = disable capture for this consumer even if global is on; Some(true) = enable capture for this consumer even if global is off (requires the ai.logging block to exist — the redactor and retention are always needed). The per-consumer toggle respects tenant preference: a consumer with capture disabled produces no stored prompts/responses.

§agent: Option<AgentPrincipal>

AI-16 (#204): agent principal metadata. Only meaningful when consumer_type is agent; ignored otherwise. Carries the agent’s display name, description, owner, and permission level for first-class agent principal attribution.

Trait Implementations§

Source§

impl Clone for Consumer

Source§

fn clone(&self) -> Consumer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Consumer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Consumer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for Consumer

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Consumer

Source§

fn eq(&self, other: &Consumer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Consumer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Consumer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyExt for T
where T: Any + ?Sized,

§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

§

fn coerce_box_to(self: Box<X>) -> Box<T>

§

fn coerce_ref_to(&self) -> &T

§

fn coerce_mut_to(&mut self) -> &mut T

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> TryIntoValue for T
where T: Serialize,

§

type Error = SerializationError

§

fn try_into_value(self) -> Result<Value, <T as TryIntoValue>::Error>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,