Interface MultiInterceptor


  • public interface MultiInterceptor
    Allow being notified when a new Multi instance is created and when this Multi receives events.

    Implementations are expected to be exposed as SPI, and so the implementation class must be declared in the META-INF/services/io.smallrye.mutiny.infrastructure.MultiInterceptor file.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_ORDINAL
      Default ordinal value.
    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default <T> Multi<T> onMultiCreation​(Multi<T> multi)
      Method called when a new instance of Multi is created.
      default <T> org.reactivestreams.Subscriber<? super T> onSubscription​(org.reactivestreams.Publisher<? extends T> instance, org.reactivestreams.Subscriber<? super T> subscriber)
      Method called when a subscriber subscribes to a Multi.
      default int ordinal()  
    • Field Detail

      • DEFAULT_ORDINAL

        static final int DEFAULT_ORDINAL
        Default ordinal value.
        See Also:
        Constant Field Values
    • Method Detail

      • ordinal

        default int ordinal()
        Returns:
        the interceptor ordinal. The ordinal is used to sort the interceptor. Lower value are executed first. Default is 100.
      • onMultiCreation

        default <T> Multi<T> onMultiCreation​(Multi<T> multi)
        Method called when a new instance of Multi is created. If can return a new Multi, or the passed Multi (default behavior) if the interceptor is not interested by this Multi.

        One use case for this method is the capture of a context at creation time (when the method is called) and restored when a subscriber subscribed to the produced multi. It is recommended to extend AbstractMulti to produce a new Multi instance.

        Type Parameters:
        T - the type of item produced by the multi
        Parameters:
        multi - the created multi
        Returns:
        the passed multi or a new instance, must not be null
      • onSubscription

        default <T> org.reactivestreams.Subscriber<? super T> onSubscription​(org.reactivestreams.Publisher<? extends T> instance,
                                                                             org.reactivestreams.Subscriber<? super T> subscriber)
        Method called when a subscriber subscribes to a Multi. This method lets you substitute the subscriber.
        Type Parameters:
        T - the type of item
        Parameters:
        instance - the instance of publisher
        subscriber - the subscriber
        Returns:
        the subscriber to use instead of the passed one. By default, it returns the given subscriber.