stores

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryEventStore

func NewMemoryEventStore(logger forge.Logger, metrics forge.Metrics) core.EventStore

NewMemoryEventStore creates a new in-memory event store.

Types

type MemoryEventStore

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

MemoryEventStore implements EventStore interface using in-memory storage.

func (*MemoryEventStore) Close

func (mes *MemoryEventStore) Close(ctx context.Context) error

Close closes the event store connection.

func (*MemoryEventStore) CreateSnapshot

func (mes *MemoryEventStore) CreateSnapshot(ctx context.Context, snapshot *core.Snapshot) error

CreateSnapshot creates a snapshot of an aggregate's state.

func (*MemoryEventStore) DeleteEvent

func (mes *MemoryEventStore) DeleteEvent(ctx context.Context, eventID string) error

func (*MemoryEventStore) DeleteEventsByAggregate

func (mes *MemoryEventStore) DeleteEventsByAggregate(ctx context.Context, aggregateID string) error

func (*MemoryEventStore) DeleteSnapshot

func (mes *MemoryEventStore) DeleteSnapshot(ctx context.Context, snapshotID string) error

func (*MemoryEventStore) GetEvent

func (mes *MemoryEventStore) GetEvent(ctx context.Context, eventID string) (*core.Event, error)

GetEvent retrieves a single event by ID.

func (*MemoryEventStore) GetEventCount

func (mes *MemoryEventStore) GetEventCount(ctx context.Context) (int64, error)

GetEventCount gets the total count of events.

func (*MemoryEventStore) GetEventCountByType

func (mes *MemoryEventStore) GetEventCountByType(ctx context.Context, eventType string) (int64, error)

GetEventCountByType gets the count of events by type.

func (*MemoryEventStore) GetEvents

func (mes *MemoryEventStore) GetEvents(ctx context.Context, criteria core.EventCriteria) (*core.EventCollection, error)

GetEvents retrieves events by various criteria.

func (*MemoryEventStore) GetEventsByAggregate

func (mes *MemoryEventStore) GetEventsByAggregate(ctx context.Context, aggregateID string, fromVersion int) ([]*core.Event, error)

GetEventsByAggregate retrieves all events for a specific aggregate.

func (*MemoryEventStore) GetEventsByType

func (mes *MemoryEventStore) GetEventsByType(ctx context.Context, eventType string, limit int, offset int64) ([]*core.Event, error)

GetEventsByType retrieves events of a specific type.

func (*MemoryEventStore) GetEventsInRange

func (mes *MemoryEventStore) GetEventsInRange(ctx context.Context, start, end time.Time, limit int, offset int64) ([]*core.Event, error)

GetEventsInRange retrieves events within a time range.

func (*MemoryEventStore) GetEventsSince

func (mes *MemoryEventStore) GetEventsSince(ctx context.Context, since time.Time, limit int, offset int64) ([]*core.Event, error)

GetEventsSince retrieves events since a specific timestamp.

func (*MemoryEventStore) GetLastEvent

func (mes *MemoryEventStore) GetLastEvent(ctx context.Context, aggregateID string) (*core.Event, error)

GetLastEvent gets the last event for an aggregate.

func (*MemoryEventStore) GetSnapshot

func (mes *MemoryEventStore) GetSnapshot(ctx context.Context, aggregateID string) (*core.Snapshot, error)

GetSnapshot retrieves the latest snapshot for an aggregate.

func (*MemoryEventStore) HealthCheck

func (mes *MemoryEventStore) HealthCheck(ctx context.Context) error

HealthCheck checks if the event store is healthy.

func (*MemoryEventStore) SaveEvent

func (mes *MemoryEventStore) SaveEvent(ctx context.Context, event *core.Event) error

SaveEvent saves a single event.

func (*MemoryEventStore) SaveEvents

func (mes *MemoryEventStore) SaveEvents(ctx context.Context, events []*core.Event) error

SaveEvents saves multiple events atomically.

type MongoEvent

type MongoEvent struct {
	ID          string         `bson:"_id"`
	AggregateID string         `bson:"aggregate_id"`
	Type        string         `bson:"type"`
	Version     int            `bson:"version"`
	Data        any            `bson:"data"`
	Metadata    map[string]any `bson:"metadata,omitempty"`
	Source      string         `bson:"source,omitempty"`
	Timestamp   time.Time      `bson:"timestamp"`
	CreatedAt   time.Time      `bson:"created_at"`
}

MongoEvent represents an event document in MongoDB.

type MongoEventStore

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

MongoEventStore implements EventStore using MongoDB.

func NewMongoEventStore

func NewMongoEventStore(client *mongo.Client, dbName string, config *core.EventStoreConfig, logger forge.Logger, metrics forge.Metrics) (*MongoEventStore, error)

NewMongoEventStore creates a new MongoDB event store.

func (*MongoEventStore) Close

func (mes *MongoEventStore) Close(ctx context.Context) error

Close implements EventStore.

func (*MongoEventStore) CreateSnapshot

func (mes *MongoEventStore) CreateSnapshot(ctx context.Context, snapshot *core.Snapshot) error

CreateSnapshot implements EventStore.

func (*MongoEventStore) GetEvent

func (mes *MongoEventStore) GetEvent(ctx context.Context, eventID string) (*core.Event, error)

GetEvent implements EventStore.

func (*MongoEventStore) GetEventsByAggregate

func (mes *MongoEventStore) GetEventsByAggregate(ctx context.Context, aggregateID string, fromVersion int) ([]*core.Event, error)

GetEventsByAggregate implements EventStore.

func (*MongoEventStore) GetEventsByType

func (mes *MongoEventStore) GetEventsByType(ctx context.Context, eventType string, fromTime, toTime time.Time) ([]*core.Event, error)

GetEventsByType implements EventStore.

func (*MongoEventStore) GetSnapshot

func (mes *MongoEventStore) GetSnapshot(ctx context.Context, aggregateID string) (*core.Snapshot, error)

GetSnapshot implements EventStore.

func (*MongoEventStore) GetStats

func (mes *MongoEventStore) GetStats() *core.EventStoreStats

GetStats implements EventStore.

func (*MongoEventStore) QueryEvents

func (mes *MongoEventStore) QueryEvents(ctx context.Context, criteria *core.EventCriteria) ([]*core.Event, error)

QueryEvents implements EventStore.

func (*MongoEventStore) SaveEvent

func (mes *MongoEventStore) SaveEvent(ctx context.Context, event *core.Event) error

SaveEvent implements EventStore.

func (*MongoEventStore) SaveEvents

func (mes *MongoEventStore) SaveEvents(ctx context.Context, events []*core.Event) error

SaveEvents implements EventStore.

type MongoSnapshot

type MongoSnapshot struct {
	ID          string         `bson:"_id"`
	AggregateID string         `bson:"aggregate_id"`
	Type        string         `bson:"type"`
	Version     int            `bson:"version"`
	Data        any            `bson:"data"`
	Metadata    map[string]any `bson:"metadata,omitempty"`
	Timestamp   time.Time      `bson:"timestamp"`
	CreatedAt   time.Time      `bson:"created_at"`
}

MongoSnapshot represents a snapshot document in MongoDB.

type PostgresEventRow

type PostgresEventRow struct {
	ID          string
	AggregateID string
	Type        string
	Version     int
	Data        []byte
	Metadata    []byte
	Source      string
	Timestamp   time.Time
	CreatedAt   time.Time
}

PostgresEventRow represents an event row in PostgreSQL.

type PostgresEventStore

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

PostgresEventStore implements EventStore using PostgreSQL.

func NewPostgresEventStore

func NewPostgresEventStore(db *sql.DB, config *core.EventStoreConfig, logger forge.Logger, metrics forge.Metrics) (*PostgresEventStore, error)

NewPostgresEventStore creates a new PostgreSQL event store.

func (*PostgresEventStore) Close

func (pes *PostgresEventStore) Close(ctx context.Context) error

Close implements EventStore.

func (*PostgresEventStore) CreateSnapshot

func (pes *PostgresEventStore) CreateSnapshot(ctx context.Context, snapshot *core.Snapshot) error

CreateSnapshot implements EventStore.

func (*PostgresEventStore) GetEvent

func (pes *PostgresEventStore) GetEvent(ctx context.Context, eventID string) (*core.Event, error)

GetEvent implements EventStore.

func (*PostgresEventStore) GetEventsByAggregate

func (pes *PostgresEventStore) GetEventsByAggregate(ctx context.Context, aggregateID string, fromVersion int) ([]*core.Event, error)

GetEventsByAggregate implements EventStore.

func (*PostgresEventStore) GetEventsByType

func (pes *PostgresEventStore) GetEventsByType(ctx context.Context, eventType string, fromTime, toTime time.Time) ([]*core.Event, error)

GetEventsByType implements EventStore.

func (*PostgresEventStore) GetSnapshot

func (pes *PostgresEventStore) GetSnapshot(ctx context.Context, aggregateID string) (*core.Snapshot, error)

GetSnapshot implements EventStore.

func (*PostgresEventStore) GetStats

func (pes *PostgresEventStore) GetStats() *core.EventStoreStats

GetStats implements EventStore.

func (*PostgresEventStore) QueryEvents

func (pes *PostgresEventStore) QueryEvents(ctx context.Context, criteria *core.EventCriteria) ([]*core.Event, error)

QueryEvents implements EventStore.

func (*PostgresEventStore) SaveEvent

func (pes *PostgresEventStore) SaveEvent(ctx context.Context, event *core.Event) error

SaveEvent implements EventStore.

func (*PostgresEventStore) SaveEvents

func (pes *PostgresEventStore) SaveEvents(ctx context.Context, events []*core.Event) error

SaveEvents implements EventStore.

type PostgresSnapshotRow

type PostgresSnapshotRow struct {
	ID          string
	AggregateID string
	Type        string
	Version     int
	Data        []byte
	Metadata    []byte
	Timestamp   time.Time
	CreatedAt   time.Time
}

PostgresSnapshotRow represents a snapshot row in PostgreSQL.

Jump to

Keyboard shortcuts

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