Skip to content

Commit 4afdd28

Browse files
clippy
1 parent 82ebc10 commit 4afdd28

5 files changed

Lines changed: 29 additions & 27 deletions

File tree

ballista/core/src/extension.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ use tonic::service::Interceptor;
3838
use tonic::transport::Endpoint;
3939
use tonic::{Request, Status};
4040

41+
/// Type alias for the endpoint override function used in gRPC client configuration
42+
pub type EndpointOverrideFn =
43+
Arc<dyn Fn(Endpoint) -> Result<Endpoint, Box<dyn Error + Send + Sync>> + Send + Sync>;
44+
4145
/// Provides methods which adapt [SessionState]
4246
/// for Ballista usage
4347
pub trait SessionStateExt {
@@ -156,11 +160,7 @@ pub trait SessionConfigExt {
156160

157161
fn with_ballista_override_create_grpc_client_endpoint(
158162
self,
159-
override_f: Arc<
160-
dyn Fn(Endpoint) -> Result<Endpoint, Box<dyn Error + Send + Sync>>
161-
+ Send
162-
+ Sync,
163-
>,
163+
override_f: EndpointOverrideFn,
164164
) -> Self;
165165

166166
fn ballista_override_create_grpc_client_endpoint(
@@ -635,19 +635,11 @@ impl Interceptor for BallistaGrpcMetadataInterceptor {
635635

636636
#[derive(Clone)]
637637
pub struct BallistaConfigGrpcEndpoint {
638-
override_f: Arc<
639-
dyn Fn(Endpoint) -> Result<Endpoint, Box<dyn Error + Send + Sync>> + Send + Sync,
640-
>,
638+
override_f: EndpointOverrideFn,
641639
}
642640

643641
impl BallistaConfigGrpcEndpoint {
644-
pub fn new(
645-
override_f: Arc<
646-
dyn Fn(Endpoint) -> Result<Endpoint, Box<dyn Error + Send + Sync>>
647-
+ Send
648-
+ Sync,
649-
>,
650-
) -> Self {
642+
pub fn new(override_f: EndpointOverrideFn) -> Self {
651643
Self { override_f }
652644
}
653645

ballista/executor/src/executor_process.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ use ballista_core::utils::{
5858
use ballista_core::{ConfigProducer, RuntimeProducer, BALLISTA_VERSION};
5959
use tonic::transport::{Endpoint, Error as TonicTransportError};
6060

61+
/// Type alias for the endpoint override function used in gRPC client configuration
62+
pub type EndpointOverrideFn =
63+
Arc<dyn Fn(Endpoint) -> Result<Endpoint, TonicTransportError> + Send + Sync>;
64+
6165
use crate::execution_engine::ExecutionEngine;
6266
use crate::executor::{Executor, TasksDrainedFuture};
6367
use crate::executor_server::TERMINATING;
@@ -106,9 +110,7 @@ pub struct ExecutorProcessConfig {
106110
/// [ArrowFlightServerProvider] implementation override option
107111
pub override_arrow_flight_service: Option<Arc<ArrowFlightServerProvider>>,
108112
/// Override function for customizing gRPC client endpoints before they are used
109-
pub override_create_grpc_client_endpoint: Option<
110-
Arc<dyn Fn(Endpoint) -> Result<Endpoint, TonicTransportError> + Send + Sync>,
111-
>,
113+
pub override_create_grpc_client_endpoint: Option<EndpointOverrideFn>,
112114
}
113115

114116
impl ExecutorProcessConfig {

ballista/executor/src/executor_server.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ use log::{debug, error, info, warn};
2727
use tonic::transport::{Channel, Endpoint, Error as TonicTransportError};
2828
use tonic::{Request, Response, Status};
2929

30+
/// Type alias for the endpoint override function used in gRPC client configuration
31+
pub type EndpointOverrideFn =
32+
Arc<dyn Fn(Endpoint) -> Result<Endpoint, TonicTransportError> + Send + Sync>;
33+
3034
use ballista_core::error::BallistaError;
3135
use ballista_core::serde::protobuf::{
3236
executor_grpc_server::{ExecutorGrpc, ExecutorGrpcServer},
@@ -184,9 +188,7 @@ pub struct ExecutorServer<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPl
184188
schedulers: SchedulerClients,
185189
grpc_max_encoding_message_size: usize,
186190
grpc_max_decoding_message_size: usize,
187-
override_create_grpc_client_endpoint: Option<
188-
Arc<dyn Fn(Endpoint) -> Result<Endpoint, TonicTransportError> + Send + Sync>,
189-
>,
191+
override_create_grpc_client_endpoint: Option<EndpointOverrideFn>,
190192
}
191193

192194
#[derive(Clone)]
@@ -213,9 +215,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan> ExecutorServer<T,
213215
codec: BallistaCodec<T, U>,
214216
grpc_max_encoding_message_size: usize,
215217
grpc_max_decoding_message_size: usize,
216-
override_create_grpc_client_endpoint: Option<
217-
Arc<dyn Fn(Endpoint) -> Result<Endpoint, TonicTransportError> + Send + Sync>,
218-
>,
218+
override_create_grpc_client_endpoint: Option<EndpointOverrideFn>,
219219
) -> Self {
220220
Self {
221221
_start_time: SystemTime::now()

ballista/scheduler/src/config.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ use std::fmt::Display;
3434
use std::sync::Arc;
3535
use tonic::transport::{Endpoint, Error as TonicTransportError};
3636

37+
/// Type alias for the endpoint override function used in gRPC client configuration
38+
pub type EndpointOverrideFn =
39+
Arc<dyn Fn(Endpoint) -> Result<Endpoint, TonicTransportError> + Send + Sync>;
40+
3741
/// Configuration of the application
3842
#[cfg(feature = "build-binary")]
3943
#[derive(clap::Parser, Debug)]
@@ -217,9 +221,7 @@ pub struct SchedulerConfig {
217221
/// [PhysicalExtensionCodec] override option
218222
pub override_physical_codec: Option<Arc<dyn PhysicalExtensionCodec>>,
219223
/// Override function for customizing gRPC client endpoints before they are used
220-
pub override_create_grpc_client_endpoint: Option<
221-
Arc<dyn Fn(Endpoint) -> Result<Endpoint, TonicTransportError> + Send + Sync>,
222-
>,
224+
pub override_create_grpc_client_endpoint: Option<EndpointOverrideFn>,
223225
}
224226

225227
impl Default for SchedulerConfig {

python/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ pub struct PyBallistaBuilder {
4747
session_config: SessionConfig,
4848
}
4949

50+
impl Default for PyBallistaBuilder {
51+
fn default() -> Self {
52+
Self::new()
53+
}
54+
}
55+
5056
#[pymethods]
5157
impl PyBallistaBuilder {
5258
#[new]

0 commit comments

Comments
 (0)