Interface EventSubscriber

All Superinterfaces:
AutoCloseable

public interface EventSubscriber extends AutoCloseable
A subscriber for events.

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 Type
    Method
    Description
    default boolean
    accepts(org.projectnessie.events.api.Event event)
    Returns whether this subscriber accepts the given event.
    default boolean
    accepts(org.projectnessie.events.api.EventType eventType)
    Returns whether this subscriber accepts the given event type.
    void
    Called when the Nessie server is stopped.
    default EventFilter
    Returns a filter that determines which events are accepted by this subscriber.
    Returns a filter that determines which event types are accepted by this subscriber.
    default boolean
    Returns whether this subscriber is blocking, that is, whether it is expected to perform blocking I/O operations when processing events.
    default void
    onCommit(org.projectnessie.events.api.CommitEvent event)
    Called when a commit is performed.
    default void
    onContentRemoved(org.projectnessie.events.api.ContentRemovedEvent event)
    Called when a content is removed (DELETE operation).
    default void
    onContentStored(org.projectnessie.events.api.ContentStoredEvent event)
    Called when a content is stored (PUT operation).
    default void
    onEvent(org.projectnessie.events.api.Event event)
    Called when any event is received from Nessie.
    default void
    onMerge(org.projectnessie.events.api.MergeEvent event)
    Called when a merge is performed.
    default void
    onReferenceCreated(org.projectnessie.events.api.ReferenceCreatedEvent event)
    Called when a reference is created.
    default void
    onReferenceDeleted(org.projectnessie.events.api.ReferenceDeletedEvent event)
    Called when a reference is deleted.
    default void
    onReferenceUpdated(org.projectnessie.events.api.ReferenceUpdatedEvent event)
    Called when a reference is updated (re-assigned).
    void
    Called when the subscriber is registered by Nessie.
    default void
    onTransplant(org.projectnessie.events.api.TransplantEvent event)
    Called when a transplant is performed.
  • Method Details

    • onSubscribe

      void onSubscribe(EventSubscription subscription)
      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

      default EventTypeFilter getEventTypeFilter()
      Returns a filter that determines which event types are accepted by this subscriber.

      By default, all event types are accepted.

    • getEventFilter

      default EventFilter 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

      void close() throws Exception
      Called when the Nessie server is stopped. Subscribers should release any resources they hold in this method.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception