@@ -28,8 +28,13 @@ pub struct ArrowFlightEndpoint {
2828 pub ( super ) task_data_entries : Arc < TTLMap < StageKey , Arc < OnceCell < TaskData > > > > ,
2929 pub ( super ) session_builder : Arc < dyn DistributedSessionBuilder + Send + Sync > ,
3030 pub ( super ) hooks : ArrowFlightEndpointHooks ,
31+ max_message_size : usize ,
3132}
3233
34+ /// Default maximum message size for FlightData chunks in ArrowFlightEndpoint.
35+ /// This is the size used for chunking FlightData within the endpoint.
36+ const DEFAULT_MESSAGE_SIZE : usize = 2 * 1024 * 1024 ; // 2 MB
37+
3338impl ArrowFlightEndpoint {
3439 pub fn try_new (
3540 session_builder : impl DistributedSessionBuilder + Send + Sync + ' static ,
@@ -40,6 +45,7 @@ impl ArrowFlightEndpoint {
4045 task_data_entries : Arc :: new ( ttl_map) ,
4146 session_builder : Arc :: new ( session_builder) ,
4247 hooks : ArrowFlightEndpointHooks :: default ( ) ,
48+ max_message_size : DEFAULT_MESSAGE_SIZE ,
4349 } )
4450 }
4551
@@ -54,6 +60,18 @@ impl ArrowFlightEndpoint {
5460 ) {
5561 self . hooks . on_plan . push ( Arc :: new ( hook) ) ;
5662 }
63+
64+ /// Set the maximum message size for FlightData chunks.
65+ /// Defaults to 2 MB.
66+ /// If you change this, ensure you configure the server's max_encoding_message_size and
67+ /// max_decoding_message_size to at least 2x this value to allow for overhead.
68+ /// If your service communication is purely internal and there is no risk of DOS attacks,
69+ /// you may want to set this to a considerably larger value to minimize the overhead of chunking
70+ /// larger datasets.
71+ pub fn with_max_message_size ( mut self , size : usize ) -> Self {
72+ self . max_message_size = size;
73+ self
74+ }
5775}
5876
5977#[ async_trait]
0 commit comments