Package org.projectnessie.events.service
Class ResultCollector
- java.lang.Object
-
- org.projectnessie.events.service.ResultCollector
-
- All Implemented Interfaces:
java.util.function.Consumer<org.projectnessie.versioned.Result>
public class ResultCollector extends java.lang.Object implements java.util.function.Consumer<org.projectnessie.versioned.Result>A collector forResults 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
EventServiceis thatEventServiceis meant to be a singleton, whileResultCollectoris meant to be instantiated per request, in order to capture the user principal that initiated the request, and the target repository id.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.Consumer<VersionStoreEvent>destinationprotected java.lang.StringrepositoryIdprotected EventSubscriberssubscribersprotected java.security.Principaluser
-
Constructor Summary
Constructors Constructor Description ResultCollector(EventSubscribers subscribers, java.lang.String repositoryId, java.security.Principal user, java.util.function.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, java.lang.String repositoryId, java.security.Principal user, EventService destination)Creates a new instance that forwards receivedResults to the givenEventServicesynchronously.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(org.projectnessie.versioned.Result result)Called when a result is produced by the version store.protected voidforwardToEventService(VersionStoreEvent event)Forwards the receivedVersionStoreEventto the destination for delivery to subscribers.protected booleanshouldProcess(org.projectnessie.versioned.Result result)Returnstrueif the givenResultshould be processed.
-
-
-
Field Detail
-
subscribers
protected final EventSubscribers subscribers
-
repositoryId
protected final java.lang.String repositoryId
-
user
protected final java.security.Principal user
-
destination
protected final java.util.function.Consumer<VersionStoreEvent> destination
-
-
Constructor Detail
-
ResultCollector
public ResultCollector(EventSubscribers subscribers, java.lang.String repositoryId, java.security.Principal user, EventService destination)
Creates a new instance that forwards receivedResults to the givenEventServicesynchronously.
-
ResultCollector
public ResultCollector(EventSubscribers subscribers, java.lang.String repositoryId, java.security.Principal user, java.util.function.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 Detail
-
accept
public void accept(org.projectnessie.versioned.Result result)
Called when a result is produced by the version store.- Specified by:
acceptin interfacejava.util.function.Consumer<org.projectnessie.versioned.Result>
-
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
protected void forwardToEventService(VersionStoreEvent event)
Forwards the receivedVersionStoreEventto the destination for delivery to subscribers.
-
-