a2a_protocol_server/dispatch/grpc/
config.rs1#[derive(Debug, Clone)]
22pub struct GrpcConfig {
23 pub max_message_size: usize,
25 pub concurrency_limit: usize,
27 pub stream_channel_capacity: usize,
29}
30
31impl Default for GrpcConfig {
32 fn default() -> Self {
33 Self {
34 max_message_size: 4 * 1024 * 1024,
35 concurrency_limit: 256,
36 stream_channel_capacity: 64,
37 }
38 }
39}
40
41impl GrpcConfig {
42 #[must_use]
44 pub const fn with_max_message_size(mut self, size: usize) -> Self {
45 self.max_message_size = size;
46 self
47 }
48
49 #[must_use]
51 pub const fn with_concurrency_limit(mut self, limit: usize) -> Self {
52 self.concurrency_limit = limit;
53 self
54 }
55
56 #[must_use]
58 pub const fn with_stream_channel_capacity(mut self, capacity: usize) -> Self {
59 self.stream_channel_capacity = capacity;
60 self
61 }
62}
63
64#[cfg(test)]
65mod tests {
66 use super::*;
67
68 #[test]
69 fn grpc_config_default_values() {
70 let config = GrpcConfig::default();
71 assert_eq!(config.max_message_size, 4 * 1024 * 1024);
72 assert_eq!(config.concurrency_limit, 256);
73 assert_eq!(config.stream_channel_capacity, 64);
74 }
75
76 #[test]
77 fn grpc_config_builders() {
78 let config = GrpcConfig::default()
79 .with_max_message_size(8 * 1024 * 1024)
80 .with_concurrency_limit(128)
81 .with_stream_channel_capacity(32);
82 assert_eq!(config.max_message_size, 8 * 1024 * 1024);
83 assert_eq!(config.concurrency_limit, 128);
84 assert_eq!(config.stream_channel_capacity, 32);
85 }
86}