Interface UniInterceptor

All Superinterfaces:
MutinyInterceptor

public interface UniInterceptor extends MutinyInterceptor
Allow being notified when a new Uni instance is created and when this Uni 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.UniInterceptor file.

  • Method Details

    • onUniCreation

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

      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 uni. It is recommended to extend AbstractUni to produce a new Uni instance.

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

      default <T> UniSubscriber<? super T> onSubscription(Uni<T> instance, UniSubscriber<? super T> subscriber)
      Method called when a subscriber subscribes to a Uni. This method lets you substitute the subscriber.
      Type Parameters:
      T - the type of item
      Parameters:
      instance - the instance of uni
      subscriber - the subscriber
      Returns:
      the subscriber to use instead of the passed one. By default, it returns the given subscriber.