evercorepostgres

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 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 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 PostgresStorageEngine

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

func NewPostgresStorageEngine

func NewPostgresStorageEngine(db *sql.DB) *PostgresStorageEngine

func NewPostgresStorageEngineWithConnection

func NewPostgresStorageEngineWithConnection(connectionString string) (*PostgresStorageEngine, error)

Creates a new Postgres backed storage engine.

func (*PostgresStorageEngine) AddSubscriptionEventType added in v0.0.42

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

func (*PostgresStorageEngine) AdvanceSubscriptionCursor added in v0.0.42

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

func (*PostgresStorageEngine) ChangeAggregateNaturalKey added in v0.0.33

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

func (*PostgresStorageEngine) ClaimSubscription added in v0.0.42

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

func (*PostgresStorageEngine) Close added in v0.0.30

func (s *PostgresStorageEngine) Close() error

func (*PostgresStorageEngine) GetAggregateById

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

func (*PostgresStorageEngine) GetAggregateByKey

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

func (*PostgresStorageEngine) GetAggregateTypeId

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

func (*PostgresStorageEngine) GetAggregateTypes

func (*PostgresStorageEngine) GetEventTypeId

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

func (*PostgresStorageEngine) GetEventTypes

func (*PostgresStorageEngine) GetEventsForAggregate

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

func (*PostgresStorageEngine) GetEventsForSubscription added in v0.0.42

func (*PostgresStorageEngine) GetFirstEventIdFromTimestamp added in v0.0.42

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

func (*PostgresStorageEngine) GetMaxEventId added in v0.0.42

func (*PostgresStorageEngine) GetMaxKeyLength

func (stor *PostgresStorageEngine) GetMaxKeyLength() int

func (*PostgresStorageEngine) GetOrCreateAggregateByKey

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

func (*PostgresStorageEngine) GetSnapshotForAggregate

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

func (*PostgresStorageEngine) GetSubscriptionByName added in v0.0.42

func (*PostgresStorageEngine) GetTransactionInfo

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

func (*PostgresStorageEngine) NewAggregate

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

func (*PostgresStorageEngine) NewAggregateWithKey

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

func (*PostgresStorageEngine) ReleaseSubscription added in v0.0.42

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

func (*PostgresStorageEngine) RenewSubscription added in v0.0.42

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

func (*PostgresStorageEngine) SetSubscriptionActive added in v0.0.42

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

func (*PostgresStorageEngine) UpsertSubscription added in v0.0.42

func (s *PostgresStorageEngine) 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 (*PostgresStorageEngine) WriteState

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) 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 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