Package org.projectnessie.events.service
Class EventService
- java.lang.Object
-
- org.projectnessie.events.service.EventService
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class EventService extends java.lang.Object implements java.lang.AutoCloseableBase class for event services.This class takes care of starting and stopping the subscribers, and provides helper methods for handling incoming results from the version store, and for firing events.
This class is meant to be used as a singleton. It provides all the required functionality to process and deliver events. Subclasses may override some of the protected methods to add support for tracing, or to implement more sophisticated delivery logic.
-
-
Field Summary
Fields Modifier and Type Field Description protected EventConfigconfigstatic java.lang.StringEVENT_ID_MDC_KEYprotected EventFactoryfactoryprotected EventSubscriberssubscribersstatic java.lang.StringSUBSCRIPTION_ID_MDC_KEY
-
Constructor Summary
Constructors Constructor Description EventService(EventConfig config, EventFactory factory, EventSubscribers subscribers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the event service by deactivating the subscribers.protected voiddeliverEvent(org.projectnessie.events.api.Event event, org.projectnessie.events.spi.EventSubscriber subscriber, org.projectnessie.events.spi.EventSubscription subscription)protected voidfireEvent(org.projectnessie.events.api.Event event)Forwards the event to all subscribers.voidonVersionStoreEvent(VersionStoreEvent event)Invoked when a result is received from the version store byResultCollector, then forwarded to this service for delivery.voidstart()Starts event delivery by activating the subscribers.
-
-
-
Field Detail
-
SUBSCRIPTION_ID_MDC_KEY
public static final java.lang.String SUBSCRIPTION_ID_MDC_KEY
- See Also:
- Constant Field Values
-
EVENT_ID_MDC_KEY
public static final java.lang.String EVENT_ID_MDC_KEY
- See Also:
- Constant Field Values
-
config
protected final EventConfig config
-
factory
protected final EventFactory factory
-
subscribers
protected final EventSubscribers subscribers
-
-
Constructor Detail
-
EventService
public EventService(EventConfig config, EventFactory factory, EventSubscribers subscribers)
-
-
Method Detail
-
start
public void start()
Starts event delivery by activating the subscribers.
-
close
public void close()
Closes the event service by deactivating the subscribers.- Specified by:
closein interfacejava.lang.AutoCloseable
-
onVersionStoreEvent
public void onVersionStoreEvent(VersionStoreEvent event)
Invoked when a result is received from the version store byResultCollector, then forwarded to this service for delivery.
-
fireEvent
protected void fireEvent(org.projectnessie.events.api.Event event)
Forwards the event to all subscribers.
-
deliverEvent
protected void deliverEvent(org.projectnessie.events.api.Event event, org.projectnessie.events.spi.EventSubscriber subscriber, org.projectnessie.events.spi.EventSubscription subscription)
-
-