Class MultiResourceUni<R,I>
- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiResourceUni<R,I>
-
- Type Parameters:
R
- the type of resourceI
- the type of item emitted by the resultingMulti
public class MultiResourceUni<R,I> extends java.lang.Object
Allows configuring a finalizer to close the resource attached to the stream. UnlikeMultiResource
, this version receives a() -> Uni<R>
, meaning that the resource instance can be resolved asynchronously.
-
-
Constructor Summary
Constructors Constructor Description MultiResourceUni(java.util.function.Supplier<Uni<R>> resourceSupplier, java.util.function.Function<? super R,? extends org.reactivestreams.Publisher<I>> streamSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Multi<I>
withFinalizer(java.util.function.Consumer<? super R> finalizer)
Configures a synchronous finalizer.Multi<I>
withFinalizer(java.util.function.Function<? super R,Uni<java.lang.Void>> finalizer)
Configures an asynchronous finalizer.Multi<I>
withFinalizer(java.util.function.Function<? super R,Uni<java.lang.Void>> onCompletion, java.util.function.BiFunction<? super R,? super java.lang.Throwable,Uni<java.lang.Void>> onFailure, java.util.function.Function<? super R,Uni<java.lang.Void>> onCancellation)
Configures asynchronous finalizers distinct for each event.
-
-
-
Method Detail
-
withFinalizer
public Multi<I> withFinalizer(java.util.function.Consumer<? super R> finalizer)
Configures a synchronous finalizer. The given function is called when the stream completes, fails or when the subscriber cancels. If the finalizer throws an exception, this exception is propagated to the subscriber, unless it has already cancelled.- Parameters:
finalizer
- the finalizer, must not benull
- Returns:
- the multi
-
withFinalizer
public Multi<I> withFinalizer(java.util.function.Function<? super R,Uni<java.lang.Void>> finalizer)
Configures an asynchronous finalizer. The given function is called when the stream completes, fails or when the subscriber cancels. The returnedUni
is flattened with the stream meaning that the subscriber gets the events fired by theUni
. If theUni
completes successfully, the subscriber gets thecompletion
event. If theUni
fails, the subscriber gets the failure even if the resource stream completed successfully. If theUni
fails after a resource stream failure, the subscriber receives aCompositeException
. If the subscribers cancels, theUni
outcome is ignored.If the finalizer throws an exception, this exception is propagated to the subscriber, unless it has already cancelled. If the finalizer returns
null
, aNullPointerException
is propagated to the subscriber, unless it has already cancelled.- Parameters:
finalizer
- the finalizer, must not benull
- Returns:
- the multi
-
withFinalizer
public Multi<I> withFinalizer(java.util.function.Function<? super R,Uni<java.lang.Void>> onCompletion, java.util.function.BiFunction<? super R,? super java.lang.Throwable,Uni<java.lang.Void>> onFailure, java.util.function.Function<? super R,Uni<java.lang.Void>> onCancellation)
Configures asynchronous finalizers distinct for each event. The given functions are called when the stream completes, fails or when the subscriber cancels.The returned
Uni
is flattened with the stream meaning that the subscriber gets the events fired by theUni
. If theUni
completes successfully, the subscriber gets thecompletion
event. If theUni
fails, the subscriber gets the failure even if the resource stream completed successfully. If theUni
fails after a resource stream failure, the subscriber receives aCompositeException
. If the subscribers cancels, theUni
outcome is ignored.If a finalizer throws an exception, this exception is propagated to the subscriber, unless it has already cancelled. If a finalizer returns
null
, aNullPointerException
is propagated to the subscriber, unless it has already cancelled.- Parameters:
onCompletion
- the completion finalizer called when the resource stream completes successfully. Must not benull
onFailure
- the failure finalizer called when the resource stream propagated a failure. The finalizer is called with the resource and the failure. Must not benull
onCancellation
- the cancellation finalizer called when the subscribers cancels the subscription. Must not benull
.- Returns:
- the multi
-
-