@@ -35,7 +35,7 @@ use std::sync::Arc;
3535use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
3636use std:: { fs:: File , pin:: Pin } ;
3737use tonic:: codegen:: StdError ;
38- use tonic:: transport:: { Channel , Endpoint , Error , Server } ;
38+ use tonic:: transport:: { Channel , Error , Server } ;
3939
4040/// Configuration for gRPC client connections.
4141///
@@ -196,21 +196,11 @@ pub async fn collect_stream(
196196 Ok ( batches)
197197}
198198
199-
200-
201199/// Creates a gRPC client connection with the specified configuration.
202-
203-
204200pub async fn create_grpc_client_connection < D > (
205201 dst : D ,
206202 config : & GrpcClientConfig ,
207203) -> std:: result:: Result < Channel , Error >
208-
209-
210- pub fn create_grpc_client_endpoint < D > ( dst : D ) -> std:: result:: Result < Endpoint , Error >
211-
212-
213-
214204where
215205 D : std:: convert:: TryInto < tonic:: transport:: Endpoint > ,
216206 D :: Error : Into < StdError > ,
@@ -231,6 +221,26 @@ where
231221 endpoint. connect ( ) . await
232222}
233223
224+ /// Creates a gRPC client endpoint (returns Endpoint without connecting).
225+ /// Used for TLS/API key customization before establishing connection.
226+ pub fn create_grpc_client_endpoint < D > ( dst : D ) -> std:: result:: Result < tonic:: transport:: Endpoint , Error >
227+ where
228+ D : std:: convert:: TryInto < tonic:: transport:: Endpoint > ,
229+ D :: Error : Into < StdError > ,
230+ {
231+ let endpoint = tonic:: transport:: Endpoint :: new ( dst) ?
232+ . connect_timeout ( Duration :: from_secs ( 20 ) )
233+ . timeout ( Duration :: from_secs ( 20 ) )
234+ // Disable Nagle's Algorithm since we don't want packets to wait
235+ . tcp_nodelay ( true )
236+ . tcp_keepalive ( Option :: Some ( Duration :: from_secs ( 3600 ) ) )
237+ . http2_keep_alive_interval ( Duration :: from_secs ( 300 ) )
238+ . keep_alive_timeout ( Duration :: from_secs ( 20 ) )
239+ . keep_alive_while_idle ( true ) ;
240+
241+ Ok ( endpoint)
242+ }
243+
234244/// Creates a gRPC server builder with the specified configuration.
235245pub fn create_grpc_server ( config : & GrpcServerConfig ) -> Server {
236246 Server :: builder ( )
@@ -270,24 +280,3 @@ pub fn get_time_before(interval_seconds: u64) -> u64 {
270280 . unwrap_or_else ( || Duration :: from_secs ( 0 ) )
271281 . as_secs ( )
272282}
273-
274- /// Create a gRPC client endpoint with configurable settings
275- ///
276- /// This is used by Spice extensions for customizing gRPC endpoint creation
277- pub fn create_grpc_client_endpoint < D > ( dst : D ) -> std:: result:: Result < Endpoint , Error >
278- where
279- D : std:: convert:: TryInto < tonic:: transport:: Endpoint > ,
280- D :: Error : Into < StdError > ,
281- {
282- let endpoint = tonic:: transport:: Endpoint :: new ( dst) ?
283- . connect_timeout ( Duration :: from_secs ( 20 ) )
284- . timeout ( Duration :: from_secs ( 20 ) )
285- // Disable Nagle's Algorithm since we don't want packets to wait
286- . tcp_nodelay ( true )
287- . tcp_keepalive ( Option :: Some ( Duration :: from_secs ( 3600 ) ) )
288- . http2_keep_alive_interval ( Duration :: from_secs ( 300 ) )
289- . keep_alive_timeout ( Duration :: from_secs ( 20 ) )
290- . keep_alive_while_idle ( true ) ;
291-
292- Ok ( endpoint)
293- }
0 commit comments