Skip to content

Commit c436a53

Browse files
Correctly propagate worker config (#371)
* correctly propagate worker config * add doctests to confirm behavior
1 parent 97b4a40 commit c436a53

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

timely/src/execute.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ where
257257

258258
let (allocators, other) = config.communication.try_build()?;
259259

260+
let worker_config = config.worker;
260261
initialize_from(allocators, other, move |allocator| {
261262

262-
let mut worker = Worker::new(WorkerConfig::default(), allocator);
263+
let mut worker = Worker::new(worker_config.clone(), allocator);
263264

264265
// If an environment variable is set, use it as the default timely logging.
265266
if let Ok(addr) = ::std::env::var("TIMELY_WORKER_LOG_ADDR") {

timely/src/worker.rs

+20
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ impl Config {
134134
/// that uniquely identifies your project, to avoid clashes. For example,
135135
/// differential dataflow registers a configuration struct under the key
136136
/// "differential".
137+
///
138+
/// # Examples
139+
/// ```rust
140+
/// let mut config = timely::Config::process(3);
141+
/// config.worker.set("example".to_string(), 7u64);
142+
/// timely::execute(config, |worker| {
143+
/// use crate::timely::worker::AsWorker;
144+
/// assert_eq!(worker.config().get::<u64>("example"), Some(&7));
145+
/// }).unwrap();
146+
/// ```
137147
pub fn set<T>(&mut self, key: String, val: T) -> &mut Self
138148
where
139149
T: Send + Sync + 'static,
@@ -147,6 +157,16 @@ impl Config {
147157
/// Returns `None` if `key` has not previously been set with
148158
/// [`WorkerConfig::set`], or if the specified `T` does not match the `T`
149159
/// from the call to `set`.
160+
///
161+
/// # Examples
162+
/// ```rust
163+
/// let mut config = timely::Config::process(3);
164+
/// config.worker.set("example".to_string(), 7u64);
165+
/// timely::execute(config, |worker| {
166+
/// use crate::timely::worker::AsWorker;
167+
/// assert_eq!(worker.config().get::<u64>("example"), Some(&7));
168+
/// }).unwrap();
169+
/// ```
150170
pub fn get<T: 'static>(&self, key: &str) -> Option<&T> {
151171
self.registry.get(key).and_then(|val| val.downcast_ref())
152172
}

0 commit comments

Comments
 (0)