Package reactor.core.observability
Interface SignalListenerFactory<T,STATE>
- Type Parameters:
T- the type of data emitted by the observed sourcePublisherSTATE- the type of the publisher-level state that will be shared between allSignalListenercreated by this factory
public interface SignalListenerFactory<T,STATE>
A factory for per-subscription
SignalListener, exposing the ability to generate common state at publisher level
from the source Publisher.
Examples of such state include:
- is the publisher a Mono? (unlocking Mono-specific behavior in the
SignalListener - resolution of NAME and TAGS on the source
- preparation of a common configuration, like a registry for metrics
- Author:
- Simon Baslé
-
Method Summary
Modifier and TypeMethodDescriptioncreateListener(Publisher<? extends T> source, ContextView listenerContext, STATE publisherContext) initializePublisherState(Publisher<? extends T> source) Create theSTATEobject for the givenPublisher.
-
Method Details
-
initializePublisherState
Create theSTATEobject for the givenPublisher. This assumes this factory will only be used on that particular source, allowing allSignalListenercreated by this factory to inherit the common state.- Parameters:
source- the sourcePublisherthis factory is attached to.- Returns:
- the common state
-
createListener
SignalListener<T> createListener(Publisher<? extends T> source, ContextView listenerContext, STATE publisherContext) Create a newSignalListenereach time a newSubscribersubscribes to thesourcePublisher.The
sourcePublisheris the same as the one that triggered common state creation at assembly time ininitializePublisherState(Publisher)). Said common state is passed to this method as well, and so is theContextViewfor the newly registeredCoreSubscriber.- Parameters:
source- the sourcePublisherthat is being subscribed tolistenerContext- theContextViewassociated with the new subscriberpublisherContext- the common state initialized ininitializePublisherState(Publisher)- Returns:
- a stateful
SignalListenerobserving signals to and from the new subscriber
-