Skip to content

Commit 17fd638

Browse files
committed
work in progress.
1 parent f46deed commit 17fd638

6 files changed

Lines changed: 21 additions & 20 deletions

File tree

rust/otap-dataflow/crates/engine/src/capability/registry/storage.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ impl Default for CapabilityRegistry {
142142

143143
impl std::fmt::Debug for CapabilityRegistry {
144144
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
145-
// The entry values are type-erased (`dyn Any` / `dyn SharedCapabilityFactory`)
146-
// and can't be printed. Summarize the shape instead.
145+
// The entry values hold type-erased produce closures
146+
// (`dyn SharedProduce` / `dyn LocalProduce`) and can't be
147+
// printed. Summarize the shape instead.
147148
f.debug_struct("CapabilityRegistry")
148149
.field("local_capabilities", &self.local.len())
149150
.field("shared_capabilities", &self.shared.len())

rust/otap-dataflow/crates/engine/src/capability/registry/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ fn test_end_to_end_shared_fresh_policy_mints_independent_instances() {
748748

749749
let bundle = ExtensionWrapper::builder(name.clone(), user_config, &runtime_config)
750750
.passive()
751-
.factory()
751+
.fresh()
752752
.shared::<FreshImpl, _>(move || {
753753
let _ = counter_for_closure.fetch_add(1, Ordering::SeqCst);
754754
FreshImpl(Arc::clone(&counter_for_closure), "fresh")

rust/otap-dataflow/crates/engine/src/extension/builder.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! // Passive extension, fresh-per-consumer policy.
2626
//! builder
2727
//! .passive()
28-
//! .factory()
28+
//! .fresh()
2929
//! .shared(|| MyShared::new(cfg.clone()))
3030
//! .local(|| Rc::new(MyLocal::new(cfg.clone())))
3131
//! .build()?;
@@ -36,7 +36,7 @@
3636
//! | Axis | Methods |
3737
//! |-----------------|----------------------------------------------------------------------------|
3838
//! | Lifecycle | `.active()` / `.passive()` |
39-
//! | Instance policy | *(implicit Cloned for Active)* `.cloned()` / `.factory()` *(Passive only)* |
39+
//! | Instance policy | *(implicit Cloned for Active)* `.cloned()` / `.fresh()` *(Passive only)* |
4040
//! | Side | `.shared(...)` / `.local(...)` *(repeatable, register once each)* |
4141
//!
4242
//! **Why the lifecycle and policy are sealed per bundle.** "This
@@ -50,10 +50,10 @@
5050
//! strategy across both sides makes the extension's behavior
5151
//! predictable and eliminates a combinatorial footgun.
5252
//!
53-
//! **Active + Factory is unrepresentable.** Active extensions have a
53+
//! **Active + Fresh is unrepresentable.** Active extensions have a
5454
//! single engine-driven event loop; minting fresh instances per
5555
//! consumer doesn't compose with that. The `.active()` stage provides
56-
//! no `.factory()` method — the invalid combination is a compile-time
56+
//! no `.fresh()` method — the invalid combination is a compile-time
5757
//! error.
5858
5959
use super::{ExtensionBundle, ExtensionLifecycle, ExtensionWrapper};
@@ -176,8 +176,8 @@ impl PassiveStage {
176176
/// Select the **fresh-per-consumer** instance policy: each consumer
177177
/// receives a freshly-constructed instance from the stored closure.
178178
#[must_use]
179-
pub fn factory(self) -> PassiveFactoryStage {
180-
PassiveFactoryStage {
179+
pub fn fresh(self) -> PassiveFreshStage {
180+
PassiveFreshStage {
181181
parent: self.parent,
182182
}
183183
}
@@ -234,13 +234,13 @@ impl PassiveClonedStage {
234234
}
235235
}
236236

237-
/// Passive + Factory (fresh-per-consumer) stage.
237+
/// Passive + Fresh (fresh-per-consumer) stage.
238238
#[doc(hidden)]
239-
pub struct PassiveFactoryStage {
239+
pub struct PassiveFreshStage {
240240
parent: ExtensionBundleBuilder,
241241
}
242242

243-
impl PassiveFactoryStage {
243+
impl PassiveFreshStage {
244244
/// Register the shared (Send) variant via a factory closure.
245245
/// Each consumer receives a freshly-constructed instance.
246246
///
@@ -337,7 +337,7 @@ impl ExtensionBundleBuilder {
337337
/// event loop is spawned; the extension exposes capabilities only.
338338
///
339339
/// Continue with [`PassiveStage::cloned`] (clone-per-consumer)
340-
/// or [`PassiveStage::factory`] (fresh-per-consumer).
340+
/// or [`PassiveStage::fresh`] (fresh-per-consumer).
341341
#[must_use]
342342
pub fn passive(self) -> PassiveStage {
343343
PassiveStage { parent: self }

rust/otap-dataflow/crates/engine/src/extension/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! | Submodule | Contents |
1010
//! |-------------|--------------------------------------------------------------------------|
1111
//! | [`wrapper`] | [`ControlChannel`], [`EffectHandler`], [`ExtensionLifecycle`], [`ExtensionWrapper`], [`ExtensionBundle`] |
12-
//! | [`builder`] | Typestate chain: [`ExtensionBundleBuilder`], [`ActiveStage`], [`PassiveStage`], [`PassiveClonedStage`], [`PassiveFactoryStage`], plus [`SharedDecomposed`] / [`LocalDecomposed`] |
12+
//! | [`builder`] | Typestate chain: [`ExtensionBundleBuilder`], [`ActiveStage`], [`PassiveStage`], [`PassiveClonedStage`], [`PassiveFreshStage`], plus [`SharedDecomposed`] / [`LocalDecomposed`] |
1313
//!
1414
//! For the local (!Send) and shared (Send) Extension traits, see
1515
//! [`local::extension`](crate::local::extension) and
@@ -22,7 +22,7 @@ pub mod wrapper;
2222
mod tests;
2323

2424
pub use builder::{
25-
ActiveStage, ExtensionBundleBuilder, LocalDecomposed, PassiveClonedStage, PassiveFactoryStage,
25+
ActiveStage, ExtensionBundleBuilder, LocalDecomposed, PassiveClonedStage, PassiveFreshStage,
2626
PassiveStage, SharedDecomposed,
2727
};
2828
pub use wrapper::{

rust/otap-dataflow/crates/engine/src/extension/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,11 @@ fn test_dual_passive() {
517517
}
518518

519519
#[test]
520-
fn test_dual_passive_factory() {
520+
fn test_dual_passive_fresh() {
521521
let (n, u, c) = ext_config("dpf");
522522
let mut set = ExtensionWrapper::builder(n, u, &c)
523523
.passive()
524-
.factory()
524+
.fresh()
525525
.local(|| std::rc::Rc::new(42u32))
526526
.shared(|| "data".to_string())
527527
.build()

rust/otap-dataflow/crates/engine/src/extension/wrapper.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ pub enum ExtensionLifecycle<E, R> {
238238
/// capability trait object.
239239
///
240240
/// The instance policy chosen at the builder (`.cloned(...)` vs
241-
/// `.factory(...)`) is baked into the stored closure:
242-
/// - **ClonePerConsumer** — the closure captures a prototype `E: Clone`
241+
/// `.fresh(...)`) is baked into the stored closure:
242+
/// - **Cloned** — the closure captures a prototype `E: Clone`
243243
/// and returns `e.clone()` on each call.
244-
/// - **FreshPerConsumer** — the closure captures the user-supplied
244+
/// - **Fresh** — the closure captures the user-supplied
245245
/// `Fn() -> E` and invokes it on each call.
246246
///
247247
/// `SharedInstanceFactory` is [`Clone`]: one extension may provide

0 commit comments

Comments
 (0)