Documentation
¶
Index ¶
- func NewMemoryEventStore(logger forge.Logger, metrics forge.Metrics) core.EventStore
- type MemoryEventStore
- func (mes *MemoryEventStore) Close(ctx context.Context) error
- func (mes *MemoryEventStore) CreateSnapshot(ctx context.Context, snapshot *core.Snapshot) error
- func (mes *MemoryEventStore) DeleteEvent(ctx context.Context, eventID string) error
- func (mes *MemoryEventStore) DeleteEventsByAggregate(ctx context.Context, aggregateID string) error
- func (mes *MemoryEventStore) DeleteSnapshot(ctx context.Context, snapshotID string) error
- func (mes *MemoryEventStore) GetEvent(ctx context.Context, eventID string) (*core.Event, error)
- func (mes *MemoryEventStore) GetEventCount(ctx context.Context) (int64, error)
- func (mes *MemoryEventStore) GetEventCountByType(ctx context.Context, eventType string) (int64, error)
- func (mes *MemoryEventStore) GetEvents(ctx context.Context, criteria core.EventCriteria) (*core.EventCollection, error)
- func (mes *MemoryEventStore) GetEventsByAggregate(ctx context.Context, aggregateID string, fromVersion int) ([]*core.Event, error)
- func (mes *MemoryEventStore) GetEventsByType(ctx context.Context, eventType string, limit int, offset int64) ([]*core.Event, error)
- func (mes *MemoryEventStore) GetEventsInRange(ctx context.Context, start, end time.Time, limit int, offset int64) ([]*core.Event, error)
- func (mes *MemoryEventStore) GetEventsSince(ctx context.Context, since time.Time, limit int, offset int64) ([]*core.Event, error)
- func (mes *MemoryEventStore) GetLastEvent(ctx context.Context, aggregateID string) (*core.Event, error)
- func (mes *MemoryEventStore) GetSnapshot(ctx context.Context, aggregateID string) (*core.Snapshot, error)
- func (mes *MemoryEventStore) HealthCheck(ctx context.Context) error
- func (mes *MemoryEventStore) SaveEvent(ctx context.Context, event *core.Event) error
- func (mes *MemoryEventStore) SaveEvents(ctx context.Context, events []*core.Event) error
- type MongoEvent
- type MongoEventStore
- func (mes *MongoEventStore) Close(ctx context.Context) error
- func (mes *MongoEventStore) CreateSnapshot(ctx context.Context, snapshot *core.Snapshot) error
- func (mes *MongoEventStore) GetEvent(ctx context.Context, eventID string) (*core.Event, error)
- func (mes *MongoEventStore) GetEventsByAggregate(ctx context.Context, aggregateID string, fromVersion int) ([]*core.Event, error)
- func (mes *MongoEventStore) GetEventsByType(ctx context.Context, eventType string, fromTime, toTime time.Time) ([]*core.Event, error)
- func (mes *MongoEventStore) GetSnapshot(ctx context.Context, aggregateID string) (*core.Snapshot, error)
- func (mes *MongoEventStore) GetStats() *core.EventStoreStats
- func (mes *MongoEventStore) QueryEvents(ctx context.Context, criteria *core.EventCriteria) ([]*core.Event, error)
- func (mes *MongoEventStore) SaveEvent(ctx context.Context, event *core.Event) error
- func (mes *MongoEventStore) SaveEvents(ctx context.Context, events []*core.Event) error
- type MongoSnapshot
- type PostgresEventRow
- type PostgresEventStore
- func (pes *PostgresEventStore) Close(ctx context.Context) error
- func (pes *PostgresEventStore) CreateSnapshot(ctx context.Context, snapshot *core.Snapshot) error
- func (pes *PostgresEventStore) GetEvent(ctx context.Context, eventID string) (*core.Event, error)
- func (pes *PostgresEventStore) GetEventsByAggregate(ctx context.Context, aggregateID string, fromVersion int) ([]*core.Event, error)
- func (pes *PostgresEventStore) GetEventsByType(ctx context.Context, eventType string, fromTime, toTime time.Time) ([]*core.Event, error)
- func (pes *PostgresEventStore) GetSnapshot(ctx context.Context, aggregateID string) (*core.Snapshot, error)
- func (pes *PostgresEventStore) GetStats() *core.EventStoreStats
- func (pes *PostgresEventStore) QueryEvents(ctx context.Context, criteria *core.EventCriteria) ([]*core.Event, error)
- func (pes *PostgresEventStore) SaveEvent(ctx context.Context, event *core.Event) error
- func (pes *PostgresEventStore) SaveEvents(ctx context.Context, events []*core.Event) error
- type PostgresSnapshotRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMemoryEventStore ¶
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 ¶
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) 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) SaveEvents ¶
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 ¶
CreateSnapshot 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) SaveEvents ¶
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 ¶
CreateSnapshot 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) SaveEvents ¶
SaveEvents implements EventStore.