Skip to content

Commit 49303cb

Browse files
author
Joe Hellerstein
committed
feat(hydro_lang): add Stream::drop_consistency() and FlowBuilder::cluster_with_consistency()
- Stream::drop_consistency(): safely forgets a consistency guarantee (e.g. EventualConsistency → NoConsistency). Purely type-level, no IR node inserted. Useful when replication strategies need to return streams on NoConsistency clusters after using broadcast_closed internally. - FlowBuilder::cluster_with_consistency<C, Con>(): creates a cluster with an explicit consistency guarantee (e.g. EventualConsistency) rather than the default NoConsistency.
1 parent f26d93a commit 49303cb

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

hydro_lang/src/compile/builder.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ impl<'a> FlowBuilder<'a> {
228228
}
229229
}
230230

231+
/// Create a cluster with a specific consistency guarantee.
232+
pub fn cluster_with_consistency<C, Con: crate::location::cluster::Consistency>(
233+
&mut self,
234+
) -> Cluster<'a, C, Con> {
235+
let key = self.locations.insert(LocationType::Cluster);
236+
self.location_names.insert(key, type_name::<C>().to_owned());
237+
Cluster {
238+
key,
239+
flow_state: self.flow_state().clone(),
240+
_phantom: PhantomData,
241+
}
242+
}
243+
231244
pub fn external<E>(&mut self) -> External<'a, E> {
232245
let key = self.locations.insert(LocationType::External);
233246
self.location_names.insert(key, type_name::<E>().to_owned());

hydro_lang/src/live_collections/stream/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,21 @@ where
521521
}
522522
}
523523

524+
/// Drop the consistency guarantee from this stream's location.
525+
///
526+
/// Weakens the consistency guarantee of this stream (e.g., going from
527+
/// `EventualConsistency` to `NoConsistency`). No IR node is inserted —
528+
/// enforcing the direction is safe. No IR node is inserted.
529+
pub fn weaken_consistency(self) -> Stream<T, L::DropConsistency, B, O, R>
530+
where
531+
L: Location<'a>,
532+
{
533+
Stream::new(
534+
self.location.drop_consistency(),
535+
self.ir_node.replace(HydroNode::Placeholder),
536+
)
537+
}
538+
524539
pub(crate) fn collection_kind() -> CollectionKind {
525540
CollectionKind::Stream {
526541
bound: B::BOUND_KIND,

0 commit comments

Comments
 (0)