Documentation ¶
Index ¶
- Variables
- type ContextExecutor
- type EventStore
- type InMemoryStore
- type PostgresSchemaAdapter
- type SQLConfig
- func NewMappingPostgresSQLConfig[T any](supportedEvents []transport.Event[T]) SQLConfig[T]
- func NewMappingSQLiteConfig[T any](supportedEvents []transport.Event[T]) SQLConfig[T]
- func NewPostgresSQLConfig[T any](supportedEvents []esja.Event[T]) SQLConfig[T]
- func NewSQLiteConfig[T any](supportedEvents []esja.Event[T]) SQLConfig[T]
- type SQLStore
- type SQLiteSchemaAdapter
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEntityNotFound = errors.New("entity not found by ID")
Functions ¶
This section is empty.
Types ¶
type ContextExecutor ¶
type ContextExecutor interface { ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) }
ContextExecutor can perform SQL queries with context.
type EventStore ¶
type EventStore[T esja.Entity[T]] interface { // Load fetches all events for the ID and returns a new instance of T based on them. Load(ctx context.Context, id string) (*T, error) // Save saves events recorded in the entity's stream. Save(ctx context.Context, entity *T) error }
EventStore loads and saves T implementing esja.Entity.
type InMemoryStore ¶
func NewInMemoryStore ¶
func NewInMemoryStore[T esja.Entity[T]]() *InMemoryStore[T]
type PostgresSchemaAdapter ¶
type PostgresSchemaAdapter[A any] struct{}
func NewPostgresSchemaAdapter ¶
func NewPostgresSchemaAdapter[A any]() PostgresSchemaAdapter[A]
func (PostgresSchemaAdapter[A]) InitializeSchemaQuery ¶
func (a PostgresSchemaAdapter[A]) InitializeSchemaQuery() string
func (PostgresSchemaAdapter[A]) InsertQuery ¶
func (a PostgresSchemaAdapter[A]) InsertQuery(streamType string, events []storageEvent[A]) (string, []any, error)
func (PostgresSchemaAdapter[A]) SelectQuery ¶
func (a PostgresSchemaAdapter[A]) SelectQuery(streamID string) (string, []any, error)
type SQLConfig ¶
type SQLConfig[T any] struct { SchemaAdapter schemaAdapter[T] Mapper transport.Mapper[T] Marshaler transport.Marshaler }
func NewMappingSQLiteConfig ¶
func NewPostgresSQLConfig ¶
type SQLStore ¶
SQLStore is an implementation of the EventStore interface using an SQLStore database.
func NewSQLStore ¶
func NewSQLStore[T esja.Entity[T]]( ctx context.Context, db ContextExecutor, config SQLConfig[T], ) (SQLStore[T], error)
NewSQLStore creates a new SQL EventStore.
type SQLiteSchemaAdapter ¶
type SQLiteSchemaAdapter[A any] struct{}
func NewSQLiteSchemaAdapter ¶
func NewSQLiteSchemaAdapter[A any]() SQLiteSchemaAdapter[A]
func (SQLiteSchemaAdapter[A]) InitializeSchemaQuery ¶
func (a SQLiteSchemaAdapter[A]) InitializeSchemaQuery() string
func (SQLiteSchemaAdapter[A]) InsertQuery ¶
func (a SQLiteSchemaAdapter[A]) InsertQuery(streamType string, events []storageEvent[A]) (string, []any, error)
func (SQLiteSchemaAdapter[A]) SelectQuery ¶
func (a SQLiteSchemaAdapter[A]) SelectQuery(streamID string) (string, []any, error)
Click to show internal directories.
Click to hide internal directories.