store

package
v0.0.0-...-dc7611c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateStore

type AggregateStore[T models.IHaveEventSourcedAggregate] interface {
	// StoreWithVersion store the new or update aggregate state with expected version
	StoreWithVersion(
		aggregate T,
		metadata metadata.Metadata,
		expectedVersion expectedStreamVersion.ExpectedStreamVersion,
		ctx context.Context) (*appendResult.AppendEventsResult, error)

	// Store the new or update aggregate state
	Store(aggregate T, metadata metadata.Metadata, ctx context.Context) (*appendResult.AppendEventsResult, error)

	// Load loads the most recent version of an aggregate to provided  into params aggregate with an id and start read position.
	Load(ctx context.Context, aggregateId uuid.UUID) (T, error)

	// LoadWithReadPosition loads the most recent version of an aggregate to provided  into params aggregate with an id and read position.
	LoadWithReadPosition(
		ctx context.Context,
		aggregateId uuid.UUID,
		position readPosition.StreamReadPosition,
	) (T, error)

	// Exists check aggregate exists by AggregateId.
	Exists(ctx context.Context, aggregateId uuid.UUID) (bool, error)
}

AggregateStore is responsible for loading and saving Aggregate.

type EventStore

type EventStore interface {
	// StreamExists Check if specific stream exists in the store
	StreamExists(streamName streamName.StreamName, ctx context.Context) (bool, error)

	// ReadEventsFromStart Read events for existing stream and start position with specified events count.
	ReadEventsFromStart(
		streamName streamName.StreamName,
		count uint64,
		ctx context.Context,
	) ([]*models.StreamEvent, error)

	// ReadEvents Read events for a specific stream and position in forward mode with specified events count.
	ReadEvents(
		streamName streamName.StreamName,
		readPosition readPosition.StreamReadPosition,
		count uint64,
		ctx context.Context,
	) ([]*models.StreamEvent, error)

	// ReadEventsWithMaxCount Read events for a specific stream and position in forward mode with max count.
	ReadEventsWithMaxCount(
		streamName streamName.StreamName,
		readPosition readPosition.StreamReadPosition,
		ctx context.Context,
	) ([]*models.StreamEvent, error)

	// ReadEventsBackwards Read events for a specific stream and position in backwards mode with specified events count.
	ReadEventsBackwards(
		streamName streamName.StreamName,
		readPosition readPosition.StreamReadPosition,
		count uint64,
		ctx context.Context,
	) ([]*models.StreamEvent, error)

	// ReadEventsBackwardsFromEnd Read events for a specific stream and end position in backwards mode with specified events count.
	ReadEventsBackwardsFromEnd(
		streamName streamName.StreamName,
		count uint64,
		ctx context.Context,
	) ([]*models.StreamEvent, error)

	// ReadEventsBackwardsWithMaxCount Read events for a specific stream and position in backwards mode with max events count.
	ReadEventsBackwardsWithMaxCount(
		stream streamName.StreamName,
		readPosition readPosition.StreamReadPosition,
		ctx context.Context,
	) ([]*models.StreamEvent, error)

	// AppendEvents Append events to aggregate with an existing or none existing stream.
	AppendEvents(
		streamName streamName.StreamName,
		expectedVersion expectedStreamVersion.ExpectedStreamVersion,
		events []*models.StreamEvent,
		ctx context.Context,
	) (*appendResult.AppendEventsResult, error)

	// AppendNewEvents Append events to aggregate with none existing stream.
	AppendNewEvents(
		streamName streamName.StreamName,
		events []*models.StreamEvent,
		ctx context.Context,
	) (*appendResult.AppendEventsResult, error)

	// TruncateStream Truncate a stream at a given position
	TruncateStream(
		streamName streamName.StreamName,
		truncatePosition truncatePosition.StreamTruncatePosition,
		expectedVersion expectedStreamVersion.ExpectedStreamVersion,
		ctx context.Context,
	) (*appendResult.AppendEventsResult, error)

	// DeleteStream Delete a stream
	DeleteStream(
		streamName streamName.StreamName,
		expectedVersion expectedStreamVersion.ExpectedStreamVersion,
		ctx context.Context,
	) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL