Package de.otto.synapse.eventsource
Interface EventSource
- All Known Implementing Classes:
AbstractEventSource,DefaultEventSource,DelegateEventSource
public interface EventSource
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<ChannelPosition>consume()Consumes all events from the EventSource, until the (current) end of the stream is reached.consumeUntil(Predicate<ShardResponse> stopCondition) Consumes all messages from the EventSource until the predicate returns true.Returns the name of the EventSource.Returns the MessageDispatcher used by the EventSource to translate and sent incoming messages to the registeredmessage consumers.Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.booleanvoidregister(MessageConsumer<?> messageConsumer) Registers a new EventConsumer at the EventSource.voidstop()
-
Method Details
-
register
Registers a new EventConsumer at the EventSource.consumershave to be thread safe as it may be called from multiple threads (e.g. for kinesis streams there is one thread per shard)- Parameters:
messageConsumer- registered EventConsumer
-
getMessageDispatcher
Returns the MessageDispatcher used by the EventSource to translate and sent incoming messages to the registeredmessage consumers.- Returns:
- MessageDispatcher
-
getMessageLogReceiverEndpoint
Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.- Returns:
- MessageLogReceiverEndpoint
-
getChannelName
String getChannelName()Returns the name of the EventSource.For streaming event-sources, this is the name of the event stream.
- Returns:
- name
-
consume
Consumes all events from the EventSource, until the (current) end of the stream is reached.The registered
consumerswill be called zero or more times, depending on the number of events retrieved from the EventSource.- Returns:
- the new read position
-
consumeUntil
@Nonnull CompletableFuture<ChannelPosition> consumeUntil(@Nonnull Predicate<ShardResponse> stopCondition) Consumes all messages from the EventSource until the predicate returns true.The registered
consumerswill be called zero or more times, depending on the number of messages retrieved from the EventSource.- Parameters:
stopCondition- the stop condition used to determine whether or not message-consumption should stop- Returns:
- the new read position
-
stop
void stop() -
isStopping
boolean isStopping()
-