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,
}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));Fields§
§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 (REST only). Default: 4096.
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 are rejected with a parse error before any individual request is dispatched.
Implementations§
Source§impl DispatchConfig
impl DispatchConfig
Sourcepub const fn with_max_request_body_size(self, size: usize) -> Self
pub const fn with_max_request_body_size(self, size: usize) -> Self
Sets the maximum request body size in bytes.
Sourcepub const fn with_body_read_timeout(self, timeout: Duration) -> Self
pub const fn with_body_read_timeout(self, timeout: Duration) -> Self
Sets the timeout for reading request bodies.
Sourcepub const fn with_max_query_string_length(self, length: usize) -> Self
pub const fn with_max_query_string_length(self, length: usize) -> Self
Sets the maximum query string length (REST only).
Sourcepub const fn with_sse_keep_alive_interval(self, interval: Duration) -> Self
pub const fn with_sse_keep_alive_interval(self, interval: Duration) -> Self
Sets the SSE keep-alive interval.
Sourcepub const fn with_sse_channel_capacity(self, capacity: usize) -> Self
pub const fn with_sse_channel_capacity(self, capacity: usize) -> Self
Sets the SSE response body channel capacity.
Sourcepub const fn with_max_batch_size(self, size: usize) -> Self
pub const fn with_max_batch_size(self, size: usize) -> Self
Sets the maximum JSON-RPC batch size.
Trait Implementations§
Source§impl Clone for DispatchConfig
impl Clone for DispatchConfig
Source§fn clone(&self) -> DispatchConfig
fn clone(&self) -> DispatchConfig
1.0.0 · 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
Auto Trait Implementations§
impl Freeze 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§
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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