eventstore

package
v0.0.0-...-2aa0edd Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 10 Imported by: 0

README

S3 Event Store

Event store implementation for estoria using AWS S3.

Storage Strategies

Single Bucket

All events for all Estoria event streams are stored in a single bucket. Each Estoria event stream maps to a subdirectory in the bucket.

Bucket Per Stream

Each Estoria event stream maps to its own S3 bucket.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultS3Client

func NewDefaultS3Client(ctx context.Context, awsConfig aws.Config) (*s3.Client, error)

Types

type EventStore

type EventStore struct {
	// contains filtered or unexported fields
}

func New

func New(s3Client *s3.Client, opts ...EventStoreOption) (*EventStore, error)

New creates a new event store using the given S3 client.

func (*EventStore) AppendStream

func (s *EventStore) AppendStream(ctx context.Context, streamID typeid.UUID, events []*eventstore.WritableEvent, opts eventstore.AppendStreamOptions) error

AppendStream appends events to the specified stream.

func (*EventStore) ReadStream

ReadStream returns an iterator for reading events from the specified stream.

type EventStoreOption

type EventStoreOption func(*EventStore) error

func WithLogger

func WithLogger(logger *slog.Logger) EventStoreOption

WithLogger sets the logger to use for the event store.

The default logger is slog.Default().

func WithStrategy

func WithStrategy(strategy Strategy) EventStoreOption

WithStrategy sets the strategy to use for the event store.

The default strategy is one collection per stream.

type Strategy

type Strategy interface {
	GetStreamIterator(
		ctx context.Context,
		streamID typeid.UUID,
		opts eventstore.ReadStreamOptions,
	) (eventstore.StreamIterator, error)
	InsertStreamEvents(
		ctx context.Context,
		streamID typeid.UUID,
		events []*eventstore.WritableEvent,
		opts eventstore.AppendStreamOptions,
	) (*strategy.InsertStreamEventsResult, error)
}

type TransactionHook

type TransactionHook interface {
	HandleEvents(sessCtx mongo.SessionContext, events []*eventstore.Event) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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