db

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBatchAlreadyClosed = errors.New("batch already closed")
)

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

type Event

type Event struct {
	Position      int64
	EventType     string
	Timestamp     time.Time
	AggregateType string
	AggregateID   uuid.UUID
	Version       int
	Data          []byte
	Metadata      []byte
}

type InsertEventsBatchResults

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

func (*InsertEventsBatchResults) Close

func (b *InsertEventsBatchResults) Close() error

func (*InsertEventsBatchResults) Query

func (b *InsertEventsBatchResults) Query(f func(int, []int64, error))

type InsertEventsParams

type InsertEventsParams struct {
	EventType     string
	Timestamp     time.Time
	AggregateType string
	AggregateID   uuid.UUID
	Version       int
	Data          []byte
	Metadata      []byte
}

type InsertSnapshotParams added in v0.2.0

type InsertSnapshotParams struct {
	AggregateType string
	AggregateID   uuid.UUID
	Version       int
	Data          []byte
	Timestamp     time.Time
}

type ListEventsByAggregateIDAndVersionParams

type ListEventsByAggregateIDAndVersionParams struct {
	AggregateID uuid.UUID
	Version     int
}

type Querier

type Querier interface {
	GetSnapshot(ctx context.Context, aggregateID uuid.UUID) (Snapshot, error)
	GetStream(ctx context.Context, id uuid.UUID) (Stream, error)
	InsertEvents(ctx context.Context, arg []InsertEventsParams) *InsertEventsBatchResults
	InsertSnapshot(ctx context.Context, arg InsertSnapshotParams) (Snapshot, error)
	ListEventsByAggregateID(ctx context.Context, aggregateID uuid.UUID) ([]Event, error)
	ListEventsByAggregateIDAndVersion(ctx context.Context, arg ListEventsByAggregateIDAndVersionParams) ([]Event, error)
	UpsertSteam(ctx context.Context, arg UpsertSteamParams) error
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GetSnapshot added in v0.2.0

func (q *Queries) GetSnapshot(ctx context.Context, aggregateID uuid.UUID) (Snapshot, error)

func (*Queries) GetStream

func (q *Queries) GetStream(ctx context.Context, id uuid.UUID) (Stream, error)

func (*Queries) InsertEvents

func (q *Queries) InsertEvents(ctx context.Context, arg []InsertEventsParams) *InsertEventsBatchResults

func (*Queries) InsertSnapshot added in v0.2.0

func (q *Queries) InsertSnapshot(ctx context.Context, arg InsertSnapshotParams) (Snapshot, error)

func (*Queries) ListEventsByAggregateID

func (q *Queries) ListEventsByAggregateID(ctx context.Context, aggregateID uuid.UUID) ([]Event, error)

func (*Queries) ListEventsByAggregateIDAndVersion

func (q *Queries) ListEventsByAggregateIDAndVersion(ctx context.Context, arg ListEventsByAggregateIDAndVersionParams) ([]Event, error)

func (*Queries) UpsertSteam

func (q *Queries) UpsertSteam(ctx context.Context, arg UpsertSteamParams) error

func (*Queries) WithTx

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

type Snapshot added in v0.2.0

type Snapshot struct {
	AggregateID   uuid.UUID
	AggregateType string
	Version       int
	Data          []byte
	Timestamp     time.Time
}

type Stream

type Stream struct {
	ID            uuid.UUID
	AggregateType string
	Position      int64
	Version       int
	UpdatedAt     time.Time
}

type UpsertSteamParams

type UpsertSteamParams struct {
	ID            uuid.UUID
	AggregateType string
	Position      int64
	Version       int
	UpdatedAt     time.Time
}

Jump to

Keyboard shortcuts

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