Interface EventSubscriber

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface EventSubscriber
    extends java.lang.AutoCloseable
    A subscriber for events.

    This is the main SPI interface that must be implemented in order to receive events from Nessie.

    Implementations must be properly registered in a META-INF/services/org.projectnessie.events.spi.EventSubscriber file. They will be then discovered and loaded by the ServiceLoader mechanism.

    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

      All Methods Instance Methods Abstract Methods Default Methods 
      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 close()
      Called when the Nessie server is stopped.
      default EventFilter getEventFilter()
      Returns a filter that determines which events are accepted by this subscriber.
      default EventTypeFilter getEventTypeFilter()
      Returns a filter that determines which event types are accepted by this subscriber.
      default boolean isBlocking()
      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 onSubscribe​(EventSubscription subscription)
      Called when the subscriber is registered by Nessie.
      default void onTransplant​(org.projectnessie.events.api.TransplantEvent event)
      Called when a transplant is performed.
    • Method Detail

      • 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 java.lang.Exception
        Called when the Nessie server is stopped. Subscribers should release any resources they hold in this method.
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception