pub struct StreamsBuilder { /* private fields */ }Expand description
The DSL entry point. Build a topology, then call build or
build_optimized.
Implementations§
Source§impl StreamsBuilder
impl StreamsBuilder
pub fn new() -> Self
Sourcepub fn stream_explicit<KS, VS>(
&self,
topics: impl IntoIterator<Item = impl Into<String>>,
consumed: impl Into<Consumed<KS, VS>>,
) -> KStream<KS::Target, VS::Target, KS, VS>
pub fn stream_explicit<KS, VS>( &self, topics: impl IntoIterator<Item = impl Into<String>>, consumed: impl Into<Consumed<KS, VS>>, ) -> KStream<KS::Target, VS::Target, KS, VS>
Source a KStream from one or more topics with explicit serdes.
Prefer StreamsBuilder::stream, the default-serde form, for types that
implement DefaultSerde. Use this escape hatch when a type has no
default serde, or to override it. Examples are a hand-rolled Serde<T>,
a key-role schema serde (AvroSerde::<T>::key(&cache)), and a
validation-on JSON serde (JsonSerde::value(&cache, true)).
Sourcepub fn table_explicit<KS, VS>(
&self,
topic: impl Into<String>,
consumed: impl Into<Consumed<KS, VS>>,
materialized: impl Into<Materialized<KS, VS>>,
) -> KTable<KS::Target, VS::Target, KS, VS>
pub fn table_explicit<KS, VS>( &self, topic: impl Into<String>, consumed: impl Into<Consumed<KS, VS>>, materialized: impl Into<Materialized<KS, VS>>, ) -> KTable<KS::Target, VS::Target, KS, VS>
Source a materialized KTable from a changelog-style topic with explicit
serdes.
Prefer StreamsBuilder::table, the default-serde form, for
DefaultSerde types. Use this method when a type has no default serde
or to override it, for example with a custom Serde<T>, a key-role
schema serde, or validated JSON.
The method records a single TableSource logical node. Its thunk lowers a
source node, the table-source processor, and the materialized state store.
The store name comes from Materialized, or from a fresh
KTABLE-SOURCE-STATE-STORE counter. The changelog topic is
<app>-<store>-changelog, unless the REUSE_KTABLE_SOURCE_TOPICS
optimizer pass, which build_optimized runs, makes it reuse the source
topic.
Sourcepub fn global_table_explicit<KS, VS>(
&self,
topic: impl Into<String>,
consumed: impl Into<Consumed<KS, VS>>,
materialized: impl Into<Materialized<KS, VS>>,
) -> GlobalKTable<KS::Target, VS::Target, KS, VS>
pub fn global_table_explicit<KS, VS>( &self, topic: impl Into<String>, consumed: impl Into<Consumed<KS, VS>>, materialized: impl Into<Materialized<KS, VS>>, ) -> GlobalKTable<KS::Target, VS::Target, KS, VS>
Source a GlobalKTable from a topic with explicit serdes. A
GlobalKTable is a fully-replicated lookup table and works only as a
join target.
Prefer StreamsBuilder::global_table, the default-serde form, for
DefaultSerde types. Use this method when a type has no default serde
or to override it, for example with a custom Serde<T>, a key-role
schema serde, or validated JSON.
The method records a single GlobalSource logical node. Its thunk calls
Topology::add_global_store to lower a source node, an
update-processor, and a global KV store. The store, the source, and the
processor are invisible in the wire, with no subtopology and no
changelog. The global source node still takes a node-group index during
grouping, so a global_table declared before stream shifts the stream
subtopology id, for example to "1". The store name comes from
materialized, or from a fresh KTABLE-SOURCE-STATE-STORE counter, and
it is minted at the JVM position, before the source name and the
processor name.
Sourcepub fn stream<K, V>(
&self,
topics: impl IntoIterator<Item = impl Into<String>>,
) -> KStream<K, V>where
K: DefaultSerde + Any + Send + Clone,
V: DefaultSerde + Any + Send + Clone,
K::Serde: SerdeAssociate<Target = K> + Clone,
V::Serde: SerdeAssociate<Target = V> + Clone,
pub fn stream<K, V>(
&self,
topics: impl IntoIterator<Item = impl Into<String>>,
) -> KStream<K, V>where
K: DefaultSerde + Any + Send + Clone,
V: DefaultSerde + Any + Send + Clone,
K::Serde: SerdeAssociate<Target = K> + Clone,
V::Serde: SerdeAssociate<Target = V> + Clone,
Source a KStream using each type’s DefaultSerde. Use
StreamsBuilder::stream_explicit to supply custom serdes.
Sourcepub fn table<K, V>(
&self,
topic: impl Into<String>,
store_name: impl Into<String>,
) -> KTable<K, V>where
K: DefaultSerde + Any + Send + Sync + Clone,
V: DefaultSerde + Any + Send + Clone,
K::Serde: SerdeAssociate<Target = K> + Clone,
V::Serde: SerdeAssociate<Target = V> + Clone,
pub fn table<K, V>(
&self,
topic: impl Into<String>,
store_name: impl Into<String>,
) -> KTable<K, V>where
K: DefaultSerde + Any + Send + Sync + Clone,
V: DefaultSerde + Any + Send + Clone,
K::Serde: SerdeAssociate<Target = K> + Clone,
V::Serde: SerdeAssociate<Target = V> + Clone,
Source a materialized KTable using each type’s DefaultSerde. Use
StreamsBuilder::table_explicit to supply custom serdes or a custom
Materialized.
Sourcepub fn global_table<K, V>(
&self,
topic: impl Into<String>,
store_name: impl Into<String>,
) -> GlobalKTable<K, V>where
K: DefaultSerde + Any + Send + Sync + Clone,
V: DefaultSerde + Any + Send + Clone,
K::Serde: SerdeAssociate<Target = K> + Clone,
V::Serde: SerdeAssociate<Target = V> + Clone,
pub fn global_table<K, V>(
&self,
topic: impl Into<String>,
store_name: impl Into<String>,
) -> GlobalKTable<K, V>where
K: DefaultSerde + Any + Send + Sync + Clone,
V: DefaultSerde + Any + Send + Clone,
K::Serde: SerdeAssociate<Target = K> + Clone,
V::Serde: SerdeAssociate<Target = V> + Clone,
Source a GlobalKTable using each type’s DefaultSerde. Use
StreamsBuilder::global_table_explicit to supply custom serdes.
Sourcepub fn add_state_store<KS, VS>(
&self,
name: impl Into<String>,
key_serde: KS,
value_serde: VS,
) -> &Self
pub fn add_state_store<KS, VS>( &self, name: impl Into<String>, key_serde: KS, value_serde: VS, ) -> &Self
Register a state store that the DSL can connect by name to a process or
process_values node.
The store is registered and its compact changelog is emitted when a
process call connects it. Call this method BEFORE the process that
names the store.
The method captures the serdes into a connect thunk. During lowering the
thunk calls Topology::add_state_store with the named processor as the
store’s connected processor, which gives the standard
<app>-<name>-changelog compact changelog. The thunk is recorded under
name, and process looks it up.
Sourcepub fn build(self, app_id: &str) -> Result<BuiltTopology, TopologyError>
pub fn build(self, app_id: &str) -> Result<BuiltTopology, TopologyError>
Build the topology with no optimizer, which is the JVM
NO_OPTIMIZATION default.
The method lowers the logical graph straight to the Processor-API
crate::topology::Topology and then finalizes it into a
BuiltTopology.
It consumes the builder, so no KStream or KTable handle may still
be alive. Each handle holds an Rc clone of the internal builder, so an
outstanding handle makes Rc::try_unwrap fail and the method panics. The
fluent stream(..).map_values(..)..to_explicit(..) form drops every
intermediate handle before build, which meets this requirement.
§Errors
Returns an error when configuration is invalid, protocol encoding fails, the broker rejects the request, or transport I/O fails.
Sourcepub fn build_optimized(
self,
app_id: &str,
) -> Result<BuiltTopology, TopologyError>
pub fn build_optimized( self, app_id: &str, ) -> Result<BuiltTopology, TopologyError>
Build the topology with the DSL optimizations on, which matches the JVM
optimization=all.
The method runs the optimizer passes over the logical graph, then lowers
the graph to the Processor-API crate::topology::Topology and
finalizes it.
There are two passes. MERGE_REPARTITION_TOPICS makes two aggregations
off one key-changing op share a single repartition topic.
REUSE_KTABLE_SOURCE_TOPICS makes a builder.table_explicit() store
reuse its source topic as its changelog. The passes are independent, so
their order does not matter. The outstanding-handle requirement is the
same as for build.
§Errors
Returns an error when configuration is invalid, protocol encoding fails, the broker rejects the request, or transport I/O fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StreamsBuilder
impl !Send for StreamsBuilder
impl !Sync for StreamsBuilder
impl !UnwindSafe for StreamsBuilder
impl Freeze for StreamsBuilder
impl Unpin for StreamsBuilder
impl UnsafeUnpin for StreamsBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);