11use crate :: {
22 ArrowFlightEndpoint , BoxCloneSyncChannel , ChannelResolver , DistributedExt ,
3- DistributedSessionBuilderContext ,
3+ DistributedSessionBuilder , DistributedSessionBuilderContext ,
4+ MappedDistributedSessionBuilderExt ,
45} ;
56use arrow_flight:: flight_service_server:: FlightServiceServer ;
67use async_trait:: async_trait;
@@ -20,12 +21,17 @@ pub struct InMemoryChannelResolver {
2021
2122impl Default for InMemoryChannelResolver {
2223 fn default ( ) -> Self {
23- Self :: new ( )
24+ Self :: new ( |ctx : DistributedSessionBuilderContext | async move {
25+ let builder = SessionStateBuilder :: new ( )
26+ . with_default_features ( )
27+ . with_runtime_env ( ctx. runtime_env . clone ( ) ) ;
28+ Ok ( builder. build ( ) )
29+ } )
2430 }
2531}
2632
2733impl InMemoryChannelResolver {
28- pub fn new ( ) -> Self {
34+ pub fn new ( builder : impl DistributedSessionBuilder + Send + Sync + ' static ) -> Self {
2935 let ( client, server) = tokio:: io:: duplex ( 1024 * 1024 ) ;
3036
3137 let mut client = Some ( client) ;
@@ -43,18 +49,10 @@ impl InMemoryChannelResolver {
4349 } ;
4450 let this_clone = this. clone ( ) ;
4551
46- let endpoint =
47- ArrowFlightEndpoint :: try_new ( move |ctx : DistributedSessionBuilderContext | {
48- let this = this. clone ( ) ;
49- async move {
50- let builder = SessionStateBuilder :: new ( )
51- . with_default_features ( )
52- . with_distributed_channel_resolver ( this)
53- . with_runtime_env ( ctx. runtime_env . clone ( ) ) ;
54- Ok ( builder. build ( ) )
55- }
56- } )
57- . unwrap ( ) ;
52+ let builder =
53+ builder. map ( move |b| Ok ( b. with_distributed_channel_resolver ( this. clone ( ) ) . build ( ) ) ) ;
54+
55+ let endpoint = ArrowFlightEndpoint :: try_new ( builder) . unwrap ( ) ;
5856
5957 tokio:: spawn ( async move {
6058 Server :: builder ( )
0 commit comments