Package de.otto.synapse.subscription
Class StateRepositorySnapshotProvider<E>
- java.lang.Object
-
- de.otto.synapse.subscription.StateRepositorySnapshotProvider<E>
-
- Type Parameters:
E-
- All Implemented Interfaces:
SnapshotProvider
public class StateRepositorySnapshotProvider<E> extends java.lang.Object implements SnapshotProvider
A SnapshotProvider that is relying on aStateRepositoryto generate the snapshot messages for a given entity-id.Using an
EntityToMessageListTransformer, the entities stored in the StateRepository can be transformed into a sequence of messages. This is especially required, if the representation of the entity does not match the payload of the snapshot messages.
-
-
Constructor Summary
Constructors Constructor Description StateRepositorySnapshotProvider(java.lang.String channelName, StateRepository<E> stateRepository)StateRepositorySnapshotProvider(java.lang.String channelName, StateRepository<E> stateRepository, EntityToMessageListTransformer<E> entityToMessagesTransformer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringchannelName()The name of the subscribable messaging channel.java.util.stream.Stream<? extends Message<?>>snapshot(java.lang.String entityId)Returns a stream containing all Messages required to get the most current snapshot for the entity that is identified by the given entityId
-
-
-
Constructor Detail
-
StateRepositorySnapshotProvider
public StateRepositorySnapshotProvider(java.lang.String channelName, StateRepository<E> stateRepository)
-
StateRepositorySnapshotProvider
public StateRepositorySnapshotProvider(java.lang.String channelName, StateRepository<E> stateRepository, EntityToMessageListTransformer<E> entityToMessagesTransformer)
-
-
Method Detail
-
channelName
public java.lang.String channelName()
Description copied from interface:SnapshotProviderThe name of the subscribable messaging channel.- Specified by:
channelNamein interfaceSnapshotProvider- Returns:
- channel name
-
snapshot
public java.util.stream.Stream<? extends Message<?>> snapshot(java.lang.String entityId)
Description copied from interface:SnapshotProviderReturns a stream containing all Messages required to get the most current snapshot for the entity that is identified by the given entityId- Specified by:
snapshotin interfaceSnapshotProvider- Parameters:
entityId- the identifier used to select a single entity.- Returns:
- Stream of messages
-
-