pub struct PartitionBy<St, Fut, F, K>{ /* private fields */ }Expand description
A stream that partitions items from an underlying stream into multiple sub-streams based on keys generated by an async function.
This struct implements Stream and yields (K, Partitioned<St, K>) tuples, where
each tuple represents a new partition with its associated key and the sub-stream
for that partition.
Items from the underlying stream are processed through the key function f, and
items with the same key are grouped together into the same partition stream.
Implementations§
Source§impl<St, Fut, F, K> PartitionBy<St, Fut, F, K>
Shared state between the main partitioning stream and all partition sub-streams.
impl<St, Fut, F, K> PartitionBy<St, Fut, F, K>
Shared state between the main partitioning stream and all partition sub-streams.
This structure coordinates the distribution of items from the source stream to the appropriate partition streams. It maintains queues of pending items for each key and tracks the overall state of the partitioning operation.
Sourcepub fn get_partition(&mut self, key: K) -> Partitioned<St, Fut, F, K>
pub fn get_partition(&mut self, key: K) -> Partitioned<St, Fut, F, K>
Sourcepub fn register_keys<I>(&mut self, keys: I)where
I: IntoIterator<Item = K>,
pub fn register_keys<I>(&mut self, keys: I)where
I: IntoIterator<Item = K>,
Sourcepub fn allows_new_partitions(&self) -> bool
pub fn allows_new_partitions(&self) -> bool
Returns whether new partitions are allowed to be created.
Sourcepub fn set_allow_new_queues(&mut self, allow: bool)
pub fn set_allow_new_queues(&mut self, allow: bool)
Sets whether new queues are allowed to be created.
If set to false, only keys that already have queues (either from previous
calls to get_partition or register_keys) will receive items. Items
for unknown keys will be dropped.