#[non_exhaustive]pub struct DispatchConfig {
pub max_request_body_size: usize,
pub body_read_timeout: Duration,
pub max_query_string_length: usize,
pub sse_keep_alive_interval: Duration,
pub sse_channel_capacity: usize,
pub max_batch_size: usize,
pub require_version_header: bool,
pub agent_card_max_age: u32,
pub base_path: Option<String>,
}Expand description
Configuration for dispatch-layer limits shared by both JSON-RPC and REST dispatchers.
All fields have sensible defaults. Create with DispatchConfig::default()
and override individual values as needed.
§Example
use a2a_protocol_server::dispatch::DispatchConfig;
let config = DispatchConfig::default()
.with_max_request_body_size(8 * 1024 * 1024)
.with_body_read_timeout(std::time::Duration::from_secs(60));#[non_exhaustive]: build it with Default and the with_* setters,
which cover every field; a struct literal is not available outside this
crate, so a field added later does not break callers.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_request_body_size: usizeMaximum request body size in bytes. Default: 4 MiB.
body_read_timeout: DurationTimeout for reading the full request body. Default: 30 seconds.
max_query_string_length: usizeMaximum query string length. Default: 4096.
Honoured by RestDispatcher, which
checks it before parsing. Not by the Axum router, which serves the
same REST routes but hands query parsing to Axum’s Query extractor —
so “REST only”, as this line used to read, named the binding when it
meant the type. What bounds a query string there is the HTTP server’s
own header limits, not this number.
sse_keep_alive_interval: DurationSSE keep-alive interval. Default: 30 seconds.
Periodic : keep-alive comments are sent at this interval to prevent
proxies and load balancers from closing idle SSE connections.
sse_channel_capacity: usizeSSE response body channel capacity. Default: 64.
Controls backpressure between the event reader task and the HTTP response body. Higher values buffer more SSE frames in memory.
max_batch_size: usizeMaximum number of requests allowed in a JSON-RPC batch. Default: 100.
Batches exceeding this limit, like an empty one, are answered Invalid Request (-32600) before any individual request is dispatched.
require_version_header: boolWhether data-plane requests must carry an A2A-Version header.
Default: true.
Spec §3.6.2: a request without the header (or with an empty value)
MUST be interpreted as protocol version 0.3 — which this server does
not implement — so by default such requests are rejected with
VersionNotSupported, exactly like the reference Python SDK.
Disable via accept_missing_version_header
for manual curl testing or trusted internal deployments.
agent_card_max_age: u32max-age, in seconds, of the Cache-Control the public agent card is
served with: spec §8.6.1 asks for one “appropriate for the agent’s
expected update frequency”. Default: 3600.
base_path: Option<String>The path prefix a reverse proxy keeps in front of every route
(/agents/billing), taken off a request’s path before it is routed:
the card is then at {prefix}/.well-known/agent-card.json and a tenant
segment comes after the prefix (audit B-08). A request outside it is
routed as before. Default: none. Read by RestDispatcher,
JsonRpcDispatcher, CombinedDispatcher and the axum A2aRouter.
Implementations§
Source§impl DispatchConfig
impl DispatchConfig
Sourcepub const fn with_max_request_body_size(self, size: usize) -> DispatchConfig
pub const fn with_max_request_body_size(self, size: usize) -> DispatchConfig
Sets the maximum request body size in bytes.
Sourcepub const fn with_body_read_timeout(self, timeout: Duration) -> DispatchConfig
pub const fn with_body_read_timeout(self, timeout: Duration) -> DispatchConfig
Sets the timeout for reading request bodies.
Sourcepub const fn with_max_query_string_length(self, length: usize) -> DispatchConfig
pub const fn with_max_query_string_length(self, length: usize) -> DispatchConfig
Sets the maximum query string length (REST only).
Sourcepub const fn with_sse_keep_alive_interval(
self,
interval: Duration,
) -> DispatchConfig
pub const fn with_sse_keep_alive_interval( self, interval: Duration, ) -> DispatchConfig
Sets the SSE keep-alive interval.
Sourcepub const fn with_sse_channel_capacity(self, capacity: usize) -> DispatchConfig
pub const fn with_sse_channel_capacity(self, capacity: usize) -> DispatchConfig
Sets the SSE response body channel capacity.
Sourcepub const fn with_max_batch_size(self, size: usize) -> DispatchConfig
pub const fn with_max_batch_size(self, size: usize) -> DispatchConfig
Sets the maximum JSON-RPC batch size.
Sourcepub const fn with_require_version_header(self, require: bool) -> DispatchConfig
pub const fn with_require_version_header(self, require: bool) -> DispatchConfig
Sets whether data-plane requests must carry an A2A-Version header.
See require_version_header;
accept_missing_version_header
is the same switch spelled for the one value most callers want.
Sourcepub const fn accept_missing_version_header(self) -> DispatchConfig
pub const fn accept_missing_version_header(self) -> DispatchConfig
Accepts data-plane requests without an A2A-Version header.
Spec §3.6.2 interprets a missing/empty header as protocol 0.3, which
this server does not implement, so the strict default rejects such
requests with VersionNotSupported (reference-SDK parity). This
opt-out restores the pre-0.7 tolerant behavior for manual testing or
deployments where every client is known to speak 1.0.
Sourcepub const fn with_agent_card_max_age(self, seconds: u32) -> DispatchConfig
pub const fn with_agent_card_max_age(self, seconds: u32) -> DispatchConfig
Sets the agent card’s Cache-Control: max-age, in seconds (spec
§8.6.1). Until 2026-10-14 every HTTP dispatcher sent 3600.
Source§impl DispatchConfig
impl DispatchConfig
Sourcepub fn with_base_path(
self,
path: impl Into<String>,
) -> Result<DispatchConfig, ServerError>
pub fn with_base_path( self, path: impl Into<String>, ) -> Result<DispatchConfig, ServerError>
Sets the base_path: / and segments of ASCII
letters, digits and -._~. A trailing / is dropped; / or "" is
none.
§Errors
ServerError::InvalidParams
for anything else (an escape, {, * or ? would route differently
on different dispatchers).
Trait Implementations§
Source§impl Clone for DispatchConfig
impl Clone for DispatchConfig
Source§fn clone(&self) -> DispatchConfig
fn clone(&self) -> DispatchConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DispatchConfig
impl Debug for DispatchConfig
Source§impl Default for DispatchConfig
impl Default for DispatchConfig
Source§fn default() -> DispatchConfig
fn default() -> DispatchConfig
Auto Trait Implementations§
impl Forget for DispatchConfig
impl Freeze for DispatchConfig
impl Move for DispatchConfig
impl RefUnwindSafe for DispatchConfig
impl Send for DispatchConfig
impl Sync for DispatchConfig
impl Unpin for DispatchConfig
impl UnsafeUnpin for DispatchConfig
impl UnwindSafe for DispatchConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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 more§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].