Class EventStoreForDynamoDB<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
- java.lang.Object
-
- com.github.j5ik2o.event.store.adapter.java.internal.EventStoreForDynamoDB<AID,A,E>
-
- All Implemented Interfaces:
EventStore<AID,A,E>,EventStoreOptions<EventStore<AID,A,E>,AID,A,E>
public final class EventStoreForDynamoDB<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>> extends java.lang.Object implements EventStore<AID,A,E>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
EventStoreForDynamoDB<AID,A,E>create(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)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.voidpersistEvent(E event, long version)Persists an event only.voidpersistEventAndSnapshot(E event, A aggregate)Persists an event and a snapshot.EventStoreForDynamoDB<AID,A,E>withDeleteTtl(java.time.Duration deleteTtl)EventStoreForDynamoDB<AID,A,E>withEventSerializer(EventSerializer<AID,E> eventSerializer)EventStoreForDynamoDB<AID,A,E>withKeepSnapshotCount(long keepSnapshotCount)EventStoreForDynamoDB<AID,A,E>withKeyResolver(KeyResolver<AID> keyResolver)EventStoreForDynamoDB<AID,A,E>withSnapshotSerializer(SnapshotSerializer<AID,A> snapshotSerializer)
-
-
-
Method Detail
-
create
public static <AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>> EventStoreForDynamoDB<AID,A,E> create(@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)
-
withKeepSnapshotCount
@Nonnull public EventStoreForDynamoDB<AID,A,E> withKeepSnapshotCount(long keepSnapshotCount)
- Specified by:
withKeepSnapshotCountin interfaceEventStoreOptions<EventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>,AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
-
withDeleteTtl
@Nonnull public EventStoreForDynamoDB<AID,A,E> withDeleteTtl(@Nonnull java.time.Duration deleteTtl)
- Specified by:
withDeleteTtlin interfaceEventStoreOptions<EventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>,AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
-
withKeyResolver
@Nonnull public EventStoreForDynamoDB<AID,A,E> withKeyResolver(@Nonnull KeyResolver<AID> keyResolver)
- Specified by:
withKeyResolverin interfaceEventStoreOptions<EventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>,AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
-
withEventSerializer
@Nonnull public EventStoreForDynamoDB<AID,A,E> withEventSerializer(@Nonnull EventSerializer<AID,E> eventSerializer)
- Specified by:
withEventSerializerin interfaceEventStoreOptions<EventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>,AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
-
withSnapshotSerializer
@Nonnull public EventStoreForDynamoDB<AID,A,E> withSnapshotSerializer(@Nonnull SnapshotSerializer<AID,A> snapshotSerializer)
- Specified by:
withSnapshotSerializerin interfaceEventStoreOptions<EventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>,AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>
-
getLatestSnapshotById
@Nonnull public java.util.Optional<A> getLatestSnapshotById(@Nonnull java.lang.Class<A> clazz, @Nonnull AID aggregateId) throws EventStoreReadException, DeserializationException
Description copied from interface:EventStoreGets the latest snapshot by the aggregate id. / 集約IDによる最新のスナップショットを取得します。- Specified by:
getLatestSnapshotByIdin interfaceEventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>- 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 public java.util.List<E> getEventsByIdSinceSequenceNumber(@Nonnull java.lang.Class<E> clazz, @Nonnull AID aggregateId, long sequenceNumber) throws DeserializationException, EventStoreReadException
Description copied from interface:EventStoreGets the events by the aggregate id and since the sequence number. / IDとシーケンス番号以降のイベントを取得します。- Specified by:
getEventsByIdSinceSequenceNumberin interfaceEventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>- Parameters:
clazz- class ofEventE to be serialized / シリアライズ対象のイベントEのクラスaggregateId- id ofAggregateA / 集約AのIDsequenceNumber- sequence number / シーケンス番号- Returns:
- events / イベント
- Throws:
DeserializationException- if an error occurred during serialization / シリアライズ中にエラーが発生した場合EventStoreReadException- if an error occurred during reading from the event store / イベントストアからの読み込み中にエラーが発生した場合
-
persistEvent
public void persistEvent(@Nonnull E event, long version) throws EventStoreWriteException, SerializationException, OptimisticLockExceptionDescription copied from interface:EventStorePersists an event only. / イベントのみを永続化します。- Specified by:
persistEventin interfaceEventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>- Parameters:
event-Eventversion- バージョン- Throws:
EventStoreWriteException- if an error occurred during writing to the event store / イベントストアへの書き込み中にエラーが発生した場合SerializationException- if an error occurred during serialization / シリアライズ中にエラーが発生した場合OptimisticLockException- if an error occurred during optimistic lock / 楽観的ロック中にエラーが発生した場合
-
persistEventAndSnapshot
public void persistEventAndSnapshot(@Nonnull E event, @Nonnull A aggregate) throws EventStoreWriteException, SerializationException, OptimisticLockExceptionDescription copied from interface:EventStorePersists an event and a snapshot. / イベントとスナップショットを永続化します。- Specified by:
persistEventAndSnapshotin interfaceEventStore<AID extends AggregateId,A extends Aggregate<A,AID>,E extends Event<AID>>- Parameters:
event-Eventaggregate-Aggregate- Throws:
EventStoreWriteException- if an error occurred during writing to the event store / イベントストアへの書き込み中にエラーが発生した場合SerializationException- if an error occurred during serialization / シリアライズ中にエラーが発生した場合OptimisticLockException- if an error occurred during optimistic lock / 楽観的ロック中にエラーが発生した場合
-
-