Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 490af86

Browse files
committed
review: doc + borrow-not-clone on worker_transport helpers
- Add method doc on set_distributed_worker_transport explaining what it does and why an embedder would call it. - Change get_distributed_worker_transport to return &Arc<dyn WorkerTransport> so callers (today only WorkerConnectionPool) can decide whether to clone.
1 parent f5ce389 commit 490af86

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/networking/worker_transport.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ use datafusion::execution::TaskContext;
55
use datafusion::prelude::SessionConfig;
66
use std::sync::{Arc, LazyLock};
77

8+
/// Stores `transport` on `cfg` so that [crate::worker::WorkerConnectionPool] picks it up at
9+
/// execute time instead of falling back to the default Flight gRPC dialer. Used by embedders
10+
/// (e.g. shared-memory transports) that want to keep DataFusion's distributed plan tree but
11+
/// swap out the network path.
812
pub(crate) fn set_distributed_worker_transport(
913
cfg: &mut SessionConfig,
1014
transport: impl WorkerTransport,
@@ -33,15 +37,15 @@ static DEFAULT_WORKER_TRANSPORT: LazyLock<Arc<dyn WorkerTransport>> =
3337
/// Returns the [WorkerTransport] registered on the session config attached to `task_ctx`, or a
3438
/// process-wide [FlightWorkerTransport] if none has been set. This is what
3539
/// [crate::worker::WorkerConnectionPool] consults at execute time when opening connections to
36-
/// remote workers.
37-
pub fn get_distributed_worker_transport(task_ctx: &TaskContext) -> Arc<dyn WorkerTransport> {
40+
/// remote workers. Returns a reference so the caller can decide whether to clone the `Arc`.
41+
pub fn get_distributed_worker_transport(task_ctx: &TaskContext) -> &Arc<dyn WorkerTransport> {
3842
let opts = task_ctx.session_config().options();
3943
if let Some(distributed_cfg) = opts.extensions.get::<DistributedConfig>()
4044
&& let Some(t) = &distributed_cfg.__private_worker_transport.0
4145
{
42-
return Arc::clone(t);
46+
return t;
4347
}
44-
Arc::clone(&DEFAULT_WORKER_TRANSPORT)
48+
&DEFAULT_WORKER_TRANSPORT
4549
}
4650

4751
#[derive(Clone, Default)]

0 commit comments

Comments
 (0)