Class MultiSplitter<T,K extends Enum<K>>

java.lang.Object
io.smallrye.mutiny.operators.multi.split.MultiSplitter<T,K>
Type Parameters:
T - the items type
K - the enumeration type

public class MultiSplitter<T,K extends Enum<K>> extends Object
Splits a Multi into several co-operating Multi.

Each split Multi receives items based on a function that maps each item to a key from an enumeration.

The demand of each split Multi is independent. Items flow when all keys from the enumeration have a split subscriber, and until either one of the split has a 0 demand, or when one of the split subscriber cancels. The flow resumes when all keys have a subscriber again, and when the demand for each split is strictly positive.

Calls to get(Enum) result in new Multi objects, but given a key K then there can be only one active subscription. If there is already a subscriber for K then any subscription request to a Multi for key K results in a terminal failure. Note that when a subscriber for K has cancelled then a request to subscribe for a Multi for K can succeed.

If the upstream Multi has already completed or failed, then any new subscriber will receive the terminal signal (see MultiSubscriber.onCompletion() and MultiSubscriber.onFailure(Throwable)).

Note on Context support: it is assumed that all split subscribers share the same Context instance, if any. The Context is passed to the upstream Multi when the first split subscription happens. When disjoint Context are in use by the different split subscribers then the behavior of your code will be most likely incorrect.

  • Constructor Details

    • MultiSplitter

      public MultiSplitter(Multi<? extends T> upstream, Class<K> keyType, Function<T,K> splitter)
  • Method Details

    • get

      @CheckReturnValue public Multi<T> get(K key)
      Get a Multi for a given key.
      Parameters:
      key - the key
      Returns:
      a new Multi
    • keyType

      public Class<K> keyType()
      Get the (enum) key type.
      Returns:
      the key type