Interface EventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
-
- Type Parameters:
AID- AggregateIdA- AggregateE- Event
- All Superinterfaces:
EventStoreOptions<EventStore<AID,A,E>,AID,A,E>
- All Known Implementing Classes:
EventStoreForDynamoDB
public interface EventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>> extends EventStoreOptions<EventStore<AID,A,E>,AID,A,E>
Represents an event store. / イベントストアを表します。
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<E>getEventsByIdSinceSequenceNumber(java.lang.Class<E> clazz, AID aggregateId, long sequenceNumber)Gets the events by the aggregate id and since the sequence number.java.util.Optional<A>getLatestSnapshotById(java.lang.Class<A> clazz, AID aggregateId)Gets the latest snapshot by the aggregate id.static <AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
EventStore<AID,A,E>ofDynamoDB(software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient, java.lang.String journalTableName, java.lang.String snapshotTableName, java.lang.String journalAidIndexName, java.lang.String snapshotAidIndexName, long shardCount)Creates an instance ofEventStorefor DynamoDB.voidpersistEvent(E event, long version)Persists an event only.voidpersistEventAndSnapshot(E event, A aggregate)Persists an event and a snapshot.-
Methods inherited from interface com.github.j5ik2o.event.store.adapter.java.EventStoreOptions
withDeleteTtl, withEventSerializer, withKeepSnapshotCount, withKeyResolver, withSnapshotSerializer
-
-
-
-
Method Detail
-
ofDynamoDB
@Nonnull static <AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>> EventStore<AID,A,E> ofDynamoDB(@Nonnull software.amazon.awssdk.services.dynamodb.DynamoDbClient dynamoDbClient, @Nonnull java.lang.String journalTableName, @Nonnull java.lang.String snapshotTableName, @Nonnull java.lang.String journalAidIndexName, @Nonnull java.lang.String snapshotAidIndexName, long shardCount)
Creates an instance ofEventStorefor DynamoDB. / DynamoDB用のEventStoreのインスタンスを作成します。- Type Parameters:
AID- aggregate id type / 集約IDの型A- aggregate type / 集約の型E- event type / イベントの型- Parameters:
dynamoDbClient-DynamoDbClientjournalTableName- journal table name / ジャーナルテーブル名snapshotTableName- snapshot table name / スナップショットテーブル名journalAidIndexName- journal aggregate id index name / ジャーナル集約IDインデックス名snapshotAidIndexName- snapshot aggregate id index name / スナップショット集約IDインデックス名shardCount- shard count / シャード数- Returns:
EventStore
-
getLatestSnapshotById
@Nonnull java.util.Optional<A> getLatestSnapshotById(@Nonnull java.lang.Class<A> clazz, @Nonnull AID aggregateId) throws EventStoreReadException, DeserializationException
Gets the latest snapshot by the aggregate id. / 集約IDによる最新のスナップショットを取得します。- Parameters:
clazz- class ofAggregateA to be serialized / シリアライズ対象の集約AのクラスaggregateId- id ofAggregateA / 集約AのID- Returns:
- latest snapshot / 最新のスナップショット
- Throws:
EventStoreReadException- if an error occurred during reading from the event store / イベントストアからの読み込み中にエラーが発生した場合DeserializationException- if an error occurred during serialization / シリアライズ中にエラーが発生した場合
-
getEventsByIdSinceSequenceNumber
@Nonnull java.util.List<E> getEventsByIdSinceSequenceNumber(@Nonnull java.lang.Class<E> clazz, @Nonnull AID aggregateId, long sequenceNumber) throws EventStoreReadException, DeserializationException
Gets the events by the aggregate id and since the sequence number. / IDとシーケンス番号以降のイベントを取得します。- Parameters:
clazz- class ofEventE to be serialized / シリアライズ対象のイベントEのクラスaggregateId- id ofAggregateA / 集約AのIDsequenceNumber- sequence number / シーケンス番号- Returns:
- events / イベント
- Throws:
EventStoreReadException- if an error occurred during reading from the event store / イベントストアからの読み込み中にエラーが発生した場合DeserializationException- if an error occurred during serialization / シリアライズ中にエラーが発生した場合
-
persistEvent
void persistEvent(@Nonnull E event, long version) throws EventStoreWriteException, SerializationException, TransactionExceptionPersists an event only. / イベントのみを永続化します。- Parameters:
event-Eventversion- バージョン- Throws:
EventStoreWriteException- if an error occurred during writing to the event store / イベントストアへの書き込み中にエラーが発生した場合SerializationException- if an error occurred during serialization / シリアライズ中にエラーが発生した場合TransactionException- if an error occurred during transaction / トランザクション中にエラーが発生した場合
-
persistEventAndSnapshot
void persistEventAndSnapshot(@Nonnull E event, @Nonnull A aggregate) throws EventStoreWriteException, SerializationException, TransactionExceptionPersists an event and a snapshot. / イベントとスナップショットを永続化します。- Parameters:
event-Eventaggregate-Aggregate- Throws:
EventStoreWriteException- if an error occurred during writing to the event store / イベントストアへの書き込み中にエラーが発生した場合SerializationException- if an error occurred during serialization / シリアライズ中にエラーが発生した場合TransactionException- if an error occurred during transaction / トランザクション中にエラーが発生した場合
-
-