evercoresqlite

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmbeddedSqliteMigrations embed.FS

Functions

func MigrateDown

func MigrateDown(db *sql.DB) error

func MigrateUp

func MigrateUp(db *sql.DB) error

func WrapError

func WrapError(msg string, err error) error

func WrapErrorf

func WrapErrorf(msg string, err error, args ...any) error

Types

type AddAggregateWithNaturalKeyParams

type AddAggregateWithNaturalKeyParams struct {
	AggregateTypeID int64
	NaturalKey      sql.NullString
}

type AddEventParams

type AddEventParams struct {
	AggregateID int64
	Sequence    int64
	EventTypeID int64
	State       string
	EventTime   time.Time
	Reference   string
}

type AddSnapshotParams

type AddSnapshotParams struct {
	AggregateID int64
	Sequence    int64
	State       string
}

type AddSubscriptionEventTypeParams added in v0.0.42

type AddSubscriptionEventTypeParams struct {
	SubscriptionID int64
	EventTypeID    int64
}

type AdvanceSubscriptionCursorParams added in v0.0.42

type AdvanceSubscriptionCursorParams struct {
	LastEventID int64
	ID          int64
}

type Aggregate

type Aggregate struct {
	ID              int64
	AggregateTypeID int64
	NaturalKey      sql.NullString
}

type AggregateType

type AggregateType struct {
	ID   int64
	Name string
}

type ChangeAggregateNaturalKeyParams added in v0.0.33

type ChangeAggregateNaturalKeyParams struct {
	NaturalKey  sql.NullString
	AggregateID int64
}

type ClaimSubscriptionParams added in v0.0.42

type ClaimSubscriptionParams struct {
	Owner          sql.NullString
	LeaseExpiresAt sql.NullTime
	Name           string
	Now            sql.NullTime
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Event

type Event struct {
	ID          int64
	AggregateID int64
	Sequence    int64
	EventTypeID int64
	State       string
	EventTime   time.Time
	Reference   string
}

type EventLog added in v0.0.42

type EventLog struct {
	ID              int64
	AggregateID     int64
	NaturalKey      sql.NullString
	Sequence        int64
	AggregateTypeID int64
	AggregateType   string
	EventTypeID     int64
	EventType       string
	EventTime       time.Time
	State           string
}

type EventType

type EventType struct {
	ID   int64
	Name string
}

type GetAggregateByIdParams

type GetAggregateByIdParams struct {
	AggregateTypeID int64
	AggregateID     int64
}

type GetAggregateByIdRow

type GetAggregateByIdRow struct {
	ID         int64
	NaturalKey sql.NullString
}

type GetAggregateIdByNaturalKeyParams

type GetAggregateIdByNaturalKeyParams struct {
	AggregateTypeID int64
	NaturalKey      sql.NullString
}

type GetEventsForAggregateParams

type GetEventsForAggregateParams struct {
	AggregateID   int64
	AfterSequence int64
}

type GetEventsForAggregateRow

type GetEventsForAggregateRow struct {
	Sequence  int64
	EventType string
	State     string
	EventTime time.Time
	Reference string
}

type GetEventsForSubscriptionParams added in v0.0.42

type GetEventsForSubscriptionParams struct {
	AfterID         int64
	AggregateTypeID interface{}
	AggregateKey    interface{}
	UseMulti        interface{}
	SubscriptionID  int64
	EventTypeID     interface{}
	Limit           int64
}

type GetMostRecentSnapshotRow

type GetMostRecentSnapshotRow struct {
	AggregateID int64
	Sequence    int64
	State       string
}

type GetSubscriptionByNameRow added in v0.0.42

type GetSubscriptionByNameRow struct {
	ID              int64
	Name            string
	AggregateTypeID sql.NullInt64
	EventTypeID     sql.NullInt64
	AggregateKey    sql.NullString
	StartFrom       string
	StartEventID    int64
	StartTimestamp  sql.NullTime
	LastEventID     int64
	Active          bool
	LeaseOwner      sql.NullString
	LeaseExpiresAt  sql.NullTime
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddAggregate

func (q *Queries) AddAggregate(ctx context.Context, aggregateTypeID int64) (int64, error)

Aggregate Queries

func (*Queries) AddAggregateType

func (q *Queries) AddAggregateType(ctx context.Context, aggregateTypeName string) (int64, error)

Aggregate Type Queries

func (*Queries) AddAggregateWithNaturalKey

func (q *Queries) AddAggregateWithNaturalKey(ctx context.Context, arg AddAggregateWithNaturalKeyParams) (int64, error)

func (*Queries) AddEvent

func (q *Queries) AddEvent(ctx context.Context, arg AddEventParams) error

Event Queries

func (*Queries) AddEventType

func (q *Queries) AddEventType(ctx context.Context, eventName string) (int64, error)

Event Type Queries

func (*Queries) AddSnapshot

func (q *Queries) AddSnapshot(ctx context.Context, arg AddSnapshotParams) error

func (*Queries) AddSubscriptionEventType added in v0.0.42

func (q *Queries) AddSubscriptionEventType(ctx context.Context, arg AddSubscriptionEventTypeParams) error

func (*Queries) AdvanceSubscriptionCursor added in v0.0.42

func (q *Queries) AdvanceSubscriptionCursor(ctx context.Context, arg AdvanceSubscriptionCursorParams) error

func (*Queries) ChangeAggregateNaturalKey added in v0.0.33

func (q *Queries) ChangeAggregateNaturalKey(ctx context.Context, arg ChangeAggregateNaturalKeyParams) error

func (*Queries) ClaimSubscription added in v0.0.42

func (q *Queries) ClaimSubscription(ctx context.Context, arg ClaimSubscriptionParams) (int64, error)

func (*Queries) GetAggregateById

func (q *Queries) GetAggregateById(ctx context.Context, arg GetAggregateByIdParams) (GetAggregateByIdRow, error)

func (*Queries) GetAggregateIdByNaturalKey

func (q *Queries) GetAggregateIdByNaturalKey(ctx context.Context, arg GetAggregateIdByNaturalKeyParams) (int64, error)

func (*Queries) GetAggregateTypeIdByName

func (q *Queries) GetAggregateTypeIdByName(ctx context.Context, aggregateTypeName string) (int64, error)

func (*Queries) GetAggregateTypes

func (q *Queries) GetAggregateTypes(ctx context.Context) ([]AggregateType, error)

func (*Queries) GetEventTypeIdByName

func (q *Queries) GetEventTypeIdByName(ctx context.Context, eventName string) (int64, error)

func (*Queries) GetEventTypes

func (q *Queries) GetEventTypes(ctx context.Context) ([]EventType, error)

func (*Queries) GetEventsForAggregate

func (q *Queries) GetEventsForAggregate(ctx context.Context, arg GetEventsForAggregateParams) ([]GetEventsForAggregateRow, error)

func (*Queries) GetEventsForSubscription added in v0.0.42

func (q *Queries) GetEventsForSubscription(ctx context.Context, arg GetEventsForSubscriptionParams) ([]EventLog, error)

func (*Queries) GetFirstEventIdFromTimestamp added in v0.0.42

func (q *Queries) GetFirstEventIdFromTimestamp(ctx context.Context, ts time.Time) (int64, error)

func (*Queries) GetMaxEventId added in v0.0.42

func (q *Queries) GetMaxEventId(ctx context.Context) (interface{}, error)

func (*Queries) GetMostRecentSnapshot

func (q *Queries) GetMostRecentSnapshot(ctx context.Context, aggregateID int64) (GetMostRecentSnapshotRow, error)

func (*Queries) GetSubscriptionByName added in v0.0.42

func (q *Queries) GetSubscriptionByName(ctx context.Context, name string) (GetSubscriptionByNameRow, error)

func (*Queries) ReleaseSubscription added in v0.0.42

func (q *Queries) ReleaseSubscription(ctx context.Context, arg ReleaseSubscriptionParams) error

func (*Queries) RenewSubscription added in v0.0.42

func (q *Queries) RenewSubscription(ctx context.Context, arg RenewSubscriptionParams) (int64, error)

func (*Queries) SetSubscriptionActive added in v0.0.42

func (q *Queries) SetSubscriptionActive(ctx context.Context, arg SetSubscriptionActiveParams) error

func (*Queries) UpsertSubscription added in v0.0.42

func (q *Queries) UpsertSubscription(ctx context.Context, arg UpsertSubscriptionParams) (int64, error)

Subscription Queries

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type ReleaseSubscriptionParams added in v0.0.42

type ReleaseSubscriptionParams struct {
	Name  string
	Owner sql.NullString
}

type RenewSubscriptionParams added in v0.0.42

type RenewSubscriptionParams struct {
	LeaseExpiresAt sql.NullTime
	Name           string
	Owner          sql.NullString
}

type SetSubscriptionActiveParams added in v0.0.42

type SetSubscriptionActiveParams struct {
	Active bool
	ID     int64
}

type Snapshot

type Snapshot struct {
	ID          int64
	AggregateID int64
	Sequence    int64
	State       string
}

type SqliteStorageEngine

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

func NewSqliteStorageEngine

func NewSqliteStorageEngine(db *sql.DB) *SqliteStorageEngine

Creates a new Sqlite3 backed storage engine.

func NewSqliteStorageEngineWithConnection

func NewSqliteStorageEngineWithConnection(connectionString string) (*SqliteStorageEngine, error)

Creates a new Sqlite backed storage engine connecting to the connection string.

func (*SqliteStorageEngine) AddSubscriptionEventType added in v0.0.42

func (s *SqliteStorageEngine) AddSubscriptionEventType(tx evercore.StorageEngineTxInfo, ctx context.Context, subscriptionId int64, eventTypeId int64) error

func (*SqliteStorageEngine) AdvanceSubscriptionCursor added in v0.0.42

func (s *SqliteStorageEngine) AdvanceSubscriptionCursor(tx evercore.StorageEngineTxInfo, ctx context.Context, id int64, lastEventId int64) error

func (*SqliteStorageEngine) ChangeAggregateNaturalKey added in v0.0.33

func (s *SqliteStorageEngine) ChangeAggregateNaturalKey(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateId int64, naturalKey string) error

func (*SqliteStorageEngine) ClaimSubscription added in v0.0.42

func (s *SqliteStorageEngine) ClaimSubscription(tx evercore.StorageEngineTxInfo, ctx context.Context, name string, owner string, lease time.Duration) (bool, error)

func (*SqliteStorageEngine) Close added in v0.0.30

func (s *SqliteStorageEngine) Close() error

func (*SqliteStorageEngine) GetAggregateById

func (s *SqliteStorageEngine) GetAggregateById(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateTypeId int64, aggregateId int64) (int64, *string, error)

func (*SqliteStorageEngine) GetAggregateByKey

func (s *SqliteStorageEngine) GetAggregateByKey(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateTypeId int64, naturalKey string) (int64, error)

func (*SqliteStorageEngine) GetAggregateTypeId

func (s *SqliteStorageEngine) GetAggregateTypeId(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateTypeName string) (int64, error)

func (*SqliteStorageEngine) GetAggregateTypes

func (*SqliteStorageEngine) GetEventTypeId

func (s *SqliteStorageEngine) GetEventTypeId(tx evercore.StorageEngineTxInfo, ctx context.Context, name string) (int64, error)

func (*SqliteStorageEngine) GetEventTypes

func (*SqliteStorageEngine) GetEventsForAggregate

func (s *SqliteStorageEngine) GetEventsForAggregate(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateId int64, afterSequence int64) ([]evercore.SerializedEvent, error)

func (*SqliteStorageEngine) GetEventsForSubscription added in v0.0.42

func (s *SqliteStorageEngine) GetEventsForSubscription(tx evercore.StorageEngineTxInfo, ctx context.Context, sub *evercore.Subscription, limit int) ([]evercore.SerializedEvent, error)

func (*SqliteStorageEngine) GetFirstEventIdFromTimestamp added in v0.0.42

func (s *SqliteStorageEngine) GetFirstEventIdFromTimestamp(tx evercore.StorageEngineTxInfo, ctx context.Context, ts time.Time) (int64, error)

func (*SqliteStorageEngine) GetMaxEventId added in v0.0.42

func (*SqliteStorageEngine) GetMaxKeyLength

func (stor *SqliteStorageEngine) GetMaxKeyLength() int

func (*SqliteStorageEngine) GetOrCreateAggregateByKey

func (s *SqliteStorageEngine) GetOrCreateAggregateByKey(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateTypeId int64, naturalKey string) (bool, int64, error)

func (*SqliteStorageEngine) GetSnapshotForAggregate

func (s *SqliteStorageEngine) GetSnapshotForAggregate(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateId int64) (*evercore.Snapshot, error)

func (*SqliteStorageEngine) GetSubscriptionByName added in v0.0.42

func (s *SqliteStorageEngine) GetSubscriptionByName(tx evercore.StorageEngineTxInfo, ctx context.Context, name string) (*evercore.Subscription, error)

func (*SqliteStorageEngine) GetTransactionInfo

func (s *SqliteStorageEngine) GetTransactionInfo() (evercore.StorageEngineTxInfo, error)

func (*SqliteStorageEngine) NewAggregate

func (s *SqliteStorageEngine) NewAggregate(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateTypeId int64) (int64, error)

func (*SqliteStorageEngine) NewAggregateWithKey

func (s *SqliteStorageEngine) NewAggregateWithKey(tx evercore.StorageEngineTxInfo, ctx context.Context, aggregateTypeId int64, naturalKey string) (int64, error)

func (*SqliteStorageEngine) ReleaseSubscription added in v0.0.42

func (s *SqliteStorageEngine) ReleaseSubscription(tx evercore.StorageEngineTxInfo, ctx context.Context, name string, owner string) error

func (*SqliteStorageEngine) RenewSubscription added in v0.0.42

func (s *SqliteStorageEngine) RenewSubscription(tx evercore.StorageEngineTxInfo, ctx context.Context, name string, owner string, lease time.Duration) (bool, error)

func (*SqliteStorageEngine) SetSubscriptionActive added in v0.0.42

func (s *SqliteStorageEngine) SetSubscriptionActive(tx evercore.StorageEngineTxInfo, ctx context.Context, id int64, active bool) error

func (*SqliteStorageEngine) UpsertSubscription added in v0.0.42

func (s *SqliteStorageEngine) UpsertSubscription(tx evercore.StorageEngineTxInfo, ctx context.Context, name string, aggregateTypeId *int64, eventTypeId *int64, aggregateKey *string, startFrom string, startEventId int64, startTimestamp *time.Time) (int64, error)

func (*SqliteStorageEngine) WriteState

type Subscription added in v0.0.42

type Subscription struct {
	ID              int64
	Name            string
	AggregateTypeID sql.NullInt64
	EventTypeID     sql.NullInt64
	AggregateKey    sql.NullString
	StartFrom       string
	StartEventID    int64
	StartTimestamp  sql.NullTime
	LastEventID     int64
	Active          bool
	LeaseOwner      sql.NullString
	LeaseExpiresAt  sql.NullTime
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type SubscriptionEventType added in v0.0.42

type SubscriptionEventType struct {
	SubscriptionID int64
	EventTypeID    int64
}

type UpsertSubscriptionParams added in v0.0.42

type UpsertSubscriptionParams struct {
	Name            string
	AggregateTypeID sql.NullInt64
	EventTypeID     sql.NullInt64
	AggregateKey    sql.NullString
	StartFrom       string
	StartEventID    int64
	StartTimestamp  sql.NullTime
}

Jump to

Keyboard shortcuts

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