Skip to content

Commit 9e1aff3

Browse files
authored
Update docs (#549)
Update docs to adhere to the `WorkerChannel` abstaction
1 parent e05109b commit 9e1aff3

6 files changed

Lines changed: 21 additions & 23 deletions

File tree

docs/source/advanced/07-worker-versioning.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ let worker = Worker::default()
2727

2828
## Querying a worker's version
2929

30-
From the coordinating context, use `DefaultChannelResolver` to get a cached
31-
channel and `create_worker_client` to build a client, then call `get_worker_info`:
30+
From the coordinating context, use `grpc::DefaultChannelResolver` to get a cached
31+
channel and `grpc::create_worker_client` to build a client, then call `get_worker_info`:
3232

3333
```rust
34-
use datafusion_distributed::{DefaultChannelResolver, GetWorkerInfoRequest, create_worker_client};
34+
use datafusion_distributed::{grpc, GetWorkerInfoRequest};
3535

36-
let channel_resolver = DefaultChannelResolver::default();
36+
let channel_resolver = grpc::DefaultChannelResolver::default();
3737
let channel = channel_resolver.get_channel(&worker_url).await?;
38-
let mut client = create_worker_client(channel);
38+
let mut client = grpc::create_worker_client(channel);
3939

4040
let response = client.get_worker_info(GetWorkerInfoRequest {}).await?;
4141
println!("version: {}", response.into_inner().version);
@@ -66,9 +66,7 @@ use std::sync::{Arc, RwLock};
6666
use std::time::Duration;
6767
use url::Url;
6868
use datafusion::common::{HashMap, DataFusionError};
69-
use datafusion_distributed::{
70-
DefaultChannelResolver, GetWorkerInfoRequest, WorkerResolver, create_worker_client,
71-
};
69+
use datafusion_distributed::{grpc, GetWorkerInfoRequest, WorkerResolver};
7270

7371
struct VersionAwareWorkerResolver {
7472
compatible_urls: Arc<RwLock<Vec<Url>>>,
@@ -80,7 +78,7 @@ async fn background_version_resolver(
8078
all_worker_urls: Vec<Url>,
8179
local_version: String,
8280
compatible_urls: Arc<RwLock<Vec<Url>>>,
83-
channel_resolver: Arc<DefaultChannelResolver>,
81+
channel_resolver: Arc<grpc::DefaultChannelResolver>,
8482
) {
8583
let mut version_cache: HashMap<Url, String> = HashMap::new();
8684

@@ -94,7 +92,7 @@ async fn background_version_resolver(
9492
let cr = Arc::clone(&channel_resolver);
9593
async move {
9694
let channel = cr.get_channel(url).await.ok()?;
97-
let mut client = create_worker_client(channel);
95+
let mut client = grpc::create_worker_client(channel);
9896
let resp = client.get_worker_info(GetWorkerInfoRequest {}).await.ok()?;
9997
Some(resp.into_inner().version)
10098
}
@@ -122,7 +120,7 @@ impl VersionAwareWorkerResolver {
122120
fn start_version_filtering(
123121
all_worker_urls: Vec<Url>,
124122
expected_version: String,
125-
channel_resolver: Arc<DefaultChannelResolver>,
123+
channel_resolver: Arc<grpc::DefaultChannelResolver>,
126124
) -> Self {
127125
let compatible_urls = Arc::new(RwLock::new(vec![]));
128126

docs/source/learn/01-concepts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ to serialized plans that get executed over the wire.
5252
Users are expected to build these and spawn them in ports so that the network
5353
boundary nodes can reach them.
5454

55-
## [WorkerResolver](https://github.com/datafusion-contrib/datafusion-distributed/blob/main/src/networking/worker_resolver.rs)
55+
## [WorkerResolver](https://github.com/datafusion-contrib/datafusion-distributed/blob/main/src/worker_resolver.rs)
5656

5757
Determines the available workers in the Distributed DataFusion cluster by
5858
returning their URLs.
@@ -87,7 +87,7 @@ logic can select the appropriate data subset. For example, task 0 of 3 might
8787
return the first third of rows, task 2 the last third, and so on. See the
8888
`TaskEstimator` documentation for guidance on which approach to use.
8989

90-
## [ChannelResolver](https://github.com/datafusion-contrib/datafusion-distributed/blob/main/src/networking/channel_resolver.rs)
90+
## [ChannelResolver](https://github.com/datafusion-contrib/datafusion-distributed/blob/main/src/protocol/channel_resolver.rs)
9191

9292
Optional extension trait that allows to customize how connections are
9393
established to workers. Given one of the URLs returned by the `WorkerResolver`,

docs/source/user-guide/06-channel-resolver.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@ pub trait ChannelResolver {
2020
async fn get_worker_client_for_url(
2121
&self,
2222
url: &Url,
23-
) -> Result<WorkerServiceClient<BoxCloneSyncChannel>, DataFusionError>;
23+
) -> Result<Box<dyn WorkerChannel>, DataFusionError>;
2424
}
2525
```
2626

2727
```{note}
2828
`get_worker_client_for_url` is called on **every** gRPC request. Reuse clients
2929
rather than reconnecting each time, or you'll open a fresh connection per request.
30-
The easiest way is to build on `DefaultChannelResolver` (which caches channels),
31-
or to use the `create_worker_client` helper.
30+
The easiest way is to build on `grpc::DefaultChannelResolver` (which caches channels),
31+
or to use the `grpc::create_worker_client` helper.
3232
```
3333

3434
## Providing your own
3535

36-
The simplest custom resolver wraps `DefaultChannelResolver`, delegating to it for
36+
The simplest custom resolver wraps `grpc::DefaultChannelResolver`, delegating to it for
3737
channel caching and only customizing what you need:
3838

3939
```rust
4040
#[derive(Clone)]
4141
struct CustomChannelResolver {
42-
inner: DefaultChannelResolver,
42+
inner: grpc::DefaultChannelResolver,
4343
}
4444

4545
#[async_trait]
4646
impl ChannelResolver for CustomChannelResolver {
4747
async fn get_worker_client_for_url(
4848
&self,
4949
url: &Url,
50-
) -> Result<WorkerServiceClient<BoxCloneSyncChannel>, DataFusionError> {
50+
) -> Result<Box<dyn WorkerChannel>, DataFusionError> {
5151
// Delegate to the default (cached channels), or build your own client
5252
// here — e.g. wrapped in tower layers, or on a custom runtime.
5353
self.inner.get_worker_client_for_url(url).await
@@ -62,7 +62,7 @@ too:
6262

6363
```rust
6464
let channel_resolver = CustomChannelResolver {
65-
inner: DefaultChannelResolver::default(),
65+
inner: grpc::DefaultChannelResolver::default(),
6666
};
6767

6868
// On the coordinating context:

examples/custom_distributed_partial_reduction_tree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Demonstrates how to **build your own distributed plan by injecting network boundaries directly**,
44
instead of relying on the automatic distributed planner to decide where the stages go.
55

6-
See the [Custom Distributed Plans user guide](../docs/source/user-guide/custom-distributed-plans.md)
6+
See the [Custom Distributed Plans guide](../docs/source/advanced/05-custom-distributed-plans.md)
77
for the concepts.
88

99
## What it shows

examples/custom_worker_url_routing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Demonstrates **custom task routing** for **cache affinity**: consistently routing each parquet file
44
to the *same* worker so that worker can serve it from an in-memory cache on repeat queries. This is
55
the
6-
[`TaskEstimator::route_tasks`](../docs/source/user-guide/task-estimator.md#routing-tasks-to-specific-workers)
6+
[`TaskEstimator::route_tasks`](../docs/source/advanced/06-worker-routing.md)
77
API.
88

99
## Scenario

examples/work_unit_feed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Demonstrates a **work unit feed**: a distributed leaf node whose work is discove
44
coordinator *at runtime* and streamed to the workers as the query executes, instead of being fully
55
known at planning time.
66

7-
See the [Work Unit Feeds user guide](../docs/source/user-guide/work-unit-feeds.md) for the concepts.
7+
See the [Work Unit Feeds guide](../docs/source/advanced/04-work-unit-feeds.md) for the concepts.
88

99
## Scenario
1010

0 commit comments

Comments
 (0)