Documentation
¶
Index ¶
- type Aggregate
- type AggregateConverter
- type AggregateId
- type AggregateResult
- type DefaultKeyResolver
- type Event
- type EventConverter
- type EventSerializer
- type EventStore
- func (es *EventStore) GetEventsByIdSinceSeqNr(aggregateId AggregateId, seqNr uint64, converter EventConverter) ([]Event, error)
- func (es *EventStore) GetLatestSnapshotById(aggregateId AggregateId, converter AggregateConverter) (*AggregateResult, error)
- func (es *EventStore) PersistEvent(event Event, version uint64) error
- func (es *EventStore) PersistEventAndSnapshot(event Event, aggregate Aggregate) error
- type EventStoreOption
- func WithDeleteTtl(deleteTtl time.Duration) EventStoreOption
- func WithEventSerializer(eventSerializer EventSerializer) EventStoreOption
- func WithKeepSnapshot(keepSnapshot bool) EventStoreOption
- func WithKeepSnapshotCount(keepSnapshotCount uint32) EventStoreOption
- func WithKeyResolver(keyResolver KeyResolver) EventStoreOption
- func WithSnapshotSerializer(snapshotSerializer SnapshotSerializer) EventStoreOption
- type JsonEventSerializer
- type JsonSnapshotSerializer
- type KeyResolver
- type SnapshotSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregateConverter ¶
type AggregateId ¶
type AggregateResult ¶ added in v0.3.4
type AggregateResult struct {
// contains filtered or unexported fields
}
func (*AggregateResult) Aggregate ¶ added in v0.3.4
func (awsv *AggregateResult) Aggregate() Aggregate
func (*AggregateResult) Empty ¶ added in v0.3.4
func (awsv *AggregateResult) Empty() bool
func (*AggregateResult) Present ¶ added in v0.3.4
func (awsv *AggregateResult) Present() bool
type DefaultKeyResolver ¶
type DefaultKeyResolver struct {
}
func (*DefaultKeyResolver) ResolvePkey ¶
func (kr *DefaultKeyResolver) ResolvePkey(aggregateId AggregateId, shardCount uint64) string
func (*DefaultKeyResolver) ResolveSkey ¶
func (kr *DefaultKeyResolver) ResolveSkey(aggregateId AggregateId, seqNr uint64) string
type EventConverter ¶
type EventSerializer ¶
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
EventStore for DynamoDB.
func NewEventStore ¶
func NewEventStore( client *dynamodb.Client, journalTableName string, snapshotTableName string, journalAidIndexName string, snapshotAidIndexName string, shardCount uint64, options ...EventStoreOption, ) (*EventStore, error)
NewEventStore returns a new EventStore.
func (*EventStore) GetEventsByIdSinceSeqNr ¶ added in v0.3.0
func (es *EventStore) GetEventsByIdSinceSeqNr(aggregateId AggregateId, seqNr uint64, converter EventConverter) ([]Event, error)
GetEventsByIdSinceSeqNr returns events by aggregateId and seqNr.
- aggregateId is an aggregateId to get events. - seqNr is a seqNr to get events. - converter is a converter to convert a map to an event.
Returns events and an error.
func (*EventStore) GetLatestSnapshotById ¶ added in v0.3.0
func (es *EventStore) GetLatestSnapshotById(aggregateId AggregateId, converter AggregateConverter) (*AggregateResult, error)
GetLatestSnapshotById returns a snapshot by aggregateId.
- aggregateId is an aggregateId to get a snapshot. - converter is a converter to convert a map to an aggregate.
Returns a snapshot and an error.
func (*EventStore) PersistEvent ¶ added in v0.3.3
func (es *EventStore) PersistEvent(event Event, version uint64) error
func (*EventStore) PersistEventAndSnapshot ¶ added in v0.3.3
func (es *EventStore) PersistEventAndSnapshot(event Event, aggregate Aggregate) error
type EventStoreOption ¶
type EventStoreOption func(*EventStore) error
EventStoreOption is an option for EventStore.
func WithDeleteTtl ¶ added in v0.3.0
func WithDeleteTtl(deleteTtl time.Duration) EventStoreOption
WithDeleteTtl sets a delete ttl.
- If you want to delete snapshots, specify a time.Duration. - If you do not want to delete snapshots, specify math.MaxInt64. - The default is math.MaxInt64.
Returns an EventStoreOption.
func WithEventSerializer ¶
func WithEventSerializer(eventSerializer EventSerializer) EventStoreOption
WithEventSerializer sets an event serializer.
- If you want to change the event serializer, specify an EventSerializer. - The default is JsonEventSerializer.
Returns an EventStoreOption.
func WithKeepSnapshot ¶ added in v0.3.0
func WithKeepSnapshot(keepSnapshot bool) EventStoreOption
WithKeepSnapshot sets whether or not to keep snapshots.
- If you want to keep snapshots, specify true. - If you do not want to keep snapshots, specify false. - The default is false.
Returns an EventStoreOption.
func WithKeepSnapshotCount ¶ added in v0.3.0
func WithKeepSnapshotCount(keepSnapshotCount uint32) EventStoreOption
WithKeepSnapshotCount sets a keep snapshot count.
- If you want to keep snapshots, specify a keep snapshot count. - If you do not want to keep snapshots, specify math.MaxInt64. - The default is math.MaxInt64.
Returns an EventStoreOption.
func WithKeyResolver ¶
func WithKeyResolver(keyResolver KeyResolver) EventStoreOption
WithKeyResolver sets a key resolver.
- If you want to change the key resolver, specify a KeyResolver. - The default is DefaultKeyResolver.
Returns an EventStoreOption.
func WithSnapshotSerializer ¶
func WithSnapshotSerializer(snapshotSerializer SnapshotSerializer) EventStoreOption
WithSnapshotSerializer sets a snapshot serializer.
- If you want to change the snapshot serializer, specify a SnapshotSerializer. - The default is JsonSnapshotSerializer.
Returns an EventStoreOption.
type JsonEventSerializer ¶
type JsonEventSerializer struct{}
func (*JsonEventSerializer) Deserialize ¶
func (s *JsonEventSerializer) Deserialize(data []byte, eventMap *map[string]interface{}) error
type JsonSnapshotSerializer ¶
type JsonSnapshotSerializer struct{}
func (*JsonSnapshotSerializer) Deserialize ¶
func (s *JsonSnapshotSerializer) Deserialize(data []byte, aggregateMap *map[string]interface{}) error
type KeyResolver ¶
type KeyResolver interface {
ResolvePkey(aggregateId AggregateId, shardCount uint64) string
ResolveSkey(aggregateId AggregateId, seqNr uint64) string
}