Interface EventSubscriber
- All Superinterfaces:
AutoCloseable
This is the main SPI interface that must be implemented in order to receive events from Nessie.
How subscribers are registered with Nessie is implementation-specific. For example, if Nessie is running on Quarkus, subscribers are typically discovered by CDI and classpath scanning.
Implementations of this interface must not block. If blocking I/O is required, then the isBlocking() method should return true.
Please note that this interface may evolve in the future, and more methods may be added. These will always be default methods, so that existing implementations will continue to work. But it is important that SPI implementers be prepared to cope with such evolutions.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanaccepts(org.projectnessie.events.api.Event event) Returns whether this subscriber accepts the given event.default booleanaccepts(org.projectnessie.events.api.EventType eventType) Returns whether this subscriber accepts the given event type.voidclose()Called when the Nessie server is stopped.default EventFilterReturns a filter that determines which events are accepted by this subscriber.default EventTypeFilterReturns a filter that determines which event types are accepted by this subscriber.default booleanReturns whether this subscriber is blocking, that is, whether it is expected to perform blocking I/O operations when processing events.default voidonCommit(org.projectnessie.events.api.CommitEvent event) Called when a commit is performed.default voidonContentRemoved(org.projectnessie.events.api.ContentRemovedEvent event) Called when a content is removed (DELETE operation).default voidonContentStored(org.projectnessie.events.api.ContentStoredEvent event) Called when a content is stored (PUT operation).default voidonEvent(org.projectnessie.events.api.Event event) Called when any event is received from Nessie.default voidonMerge(org.projectnessie.events.api.MergeEvent event) Called when a merge is performed.default voidonReferenceCreated(org.projectnessie.events.api.ReferenceCreatedEvent event) Called when a reference is created.default voidonReferenceDeleted(org.projectnessie.events.api.ReferenceDeletedEvent event) Called when a reference is deleted.default voidonReferenceUpdated(org.projectnessie.events.api.ReferenceUpdatedEvent event) Called when a reference is updated (re-assigned).voidonSubscribe(EventSubscription subscription) Called when the subscriber is registered by Nessie.default voidonTransplant(org.projectnessie.events.api.TransplantEvent event) Called when a transplant is performed.
-
Method Details
-
onSubscribe
Called when the subscriber is registered by Nessie.Any initialization work, such as reading configuration, opening remote connections, etc., should be done here, and not in the constructor.
-
isBlocking
default boolean isBlocking()Returns whether this subscriber is blocking, that is, whether it is expected to perform blocking I/O operations when processing events.Event delivery to blocking subscribers is done in a separate thread pool, so that they do not block Nessie's internal event queue.
-
getEventTypeFilter
Returns a filter that determines which event types are accepted by this subscriber.By default, all event types are accepted.
-
getEventFilter
Returns a filter that determines which events are accepted by this subscriber.By default, all events are accepted.
-
accepts
default boolean accepts(org.projectnessie.events.api.EventType eventType) Returns whether this subscriber accepts the given event type.If this method returns
false, no events of this type will be delivered to the subscriber. -
accepts
default boolean accepts(org.projectnessie.events.api.Event event) Returns whether this subscriber accepts the given event.If this method returns
false, this specific event will not be delivered to the subscriber. -
onReferenceCreated
default void onReferenceCreated(org.projectnessie.events.api.ReferenceCreatedEvent event) Called when a reference is created. -
onReferenceUpdated
default void onReferenceUpdated(org.projectnessie.events.api.ReferenceUpdatedEvent event) Called when a reference is updated (re-assigned). -
onReferenceDeleted
default void onReferenceDeleted(org.projectnessie.events.api.ReferenceDeletedEvent event) Called when a reference is deleted. -
onCommit
default void onCommit(org.projectnessie.events.api.CommitEvent event) Called when a commit is performed. -
onMerge
default void onMerge(org.projectnessie.events.api.MergeEvent event) Called when a merge is performed. -
onTransplant
default void onTransplant(org.projectnessie.events.api.TransplantEvent event) Called when a transplant is performed. -
onContentStored
default void onContentStored(org.projectnessie.events.api.ContentStoredEvent event) Called when a content is stored (PUT operation). -
onContentRemoved
default void onContentRemoved(org.projectnessie.events.api.ContentRemovedEvent event) Called when a content is removed (DELETE operation). -
onEvent
default void onEvent(org.projectnessie.events.api.Event event) Called when any event is received from Nessie. The default implementation simply dispatches to the more specific methods. -
close
Called when the Nessie server is stopped. Subscribers should release any resources they hold in this method.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-