Package org.projectnessie.events.service
Class ResultCollector
java.lang.Object
org.projectnessie.events.service.ResultCollector
- All Implemented Interfaces:
Consumer<org.projectnessie.versioned.Result>
A collector for
Results produced by the version store.
Instances of this class are meant to be injected into version stores to collect results.
The main reason why this functionality is not part of the EventService is that EventService is meant to be a singleton, while ResultCollector is meant to be
instantiated per request, in order to capture the user principal that initiated the request, and
the target repository id.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Consumer<VersionStoreEvent>protected final Stringprotected final EventSubscribersprotected final Principal -
Constructor Summary
ConstructorsConstructorDescriptionResultCollector(EventSubscribers subscribers, String repositoryId, Principal user, Consumer<VersionStoreEvent> destination) Creates a new instance that forwards receivedResults to the givenConsumer, allowing implementers to control how the event is delivered to theEventService.ResultCollector(EventSubscribers subscribers, String repositoryId, Principal user, EventService destination) Creates a new instance that forwards receivedResults to the givenEventServicesynchronously. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(org.projectnessie.versioned.Result result) Called when a result is produced by the version store.protected voidForwards the receivedVersionStoreEventto the destination for delivery to subscribers.protected booleanshouldProcess(org.projectnessie.versioned.Result result) Returnstrueif the givenResultshould be processed.
-
Field Details
-
subscribers
-
repositoryId
-
user
-
destination
-
-
Constructor Details
-
ResultCollector
public ResultCollector(EventSubscribers subscribers, String repositoryId, Principal user, EventService destination) Creates a new instance that forwards receivedResults to the givenEventServicesynchronously. -
ResultCollector
public ResultCollector(EventSubscribers subscribers, String repositoryId, Principal user, Consumer<VersionStoreEvent> destination) Creates a new instance that forwards receivedResults to the givenConsumer, allowing implementers to control how the event is delivered to theEventService.
-
-
Method Details
-
accept
public void accept(org.projectnessie.versioned.Result result) Called when a result is produced by the version store. -
shouldProcess
protected boolean shouldProcess(org.projectnessie.versioned.Result result) Returnstrueif the givenResultshould be processed.This acts as an early filter to remove results that are not relevant to any of the subscribers.
-
forwardToEventService
Forwards the receivedVersionStoreEventto the destination for delivery to subscribers.
-