db

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInvalidSequenceNumber

func ErrInvalidSequenceNumber(seq int32) error

func RunMigrations

func RunMigrations(ctx context.Context, logger Logger, connParams Configurator, fs FilesystemProvider, stopAfter int32, printSummary bool) (fault error)

Types

type Configurator added in v0.3.1

type Configurator interface {
	DBConStr() string
}

type DBMigrator

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

func NewMigrator

func NewMigrator(ctx context.Context, logger Logger, connParams Configurator, fs FilesystemProvider) (migrator DBMigrator, fault error)

func (DBMigrator) Info

func (m DBMigrator) Info(stopAfter int32) (information Info, fault error)

func (*DBMigrator) Migrate

func (m *DBMigrator) Migrate() (fault error)

func (*DBMigrator) MigrateTo

func (m *DBMigrator) MigrateTo(sequence int32) (fault error)

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
}

type FilesystemProvider added in v0.3.1

type FilesystemProvider interface {
	ReadDir(name string) ([]fs.FileInfo, error)
	ReadFile(name string) ([]byte, error)
	Open(name string) (fs.File, error)
}

type Info

type Info struct {
	DBConnStr  string
	Port       string
	Database   string
	Migrations MigrationInfo
}

type Logger

type Logger interface {
	Debug(msg string, ephemeralArgs ...any)
	Info(msg string, ephemeralArgs ...any)
	Error(msg string, err error, severity string, ephemeralArgs ...any)
}

type MigrationFS

type MigrationFS struct {
	FS embed.FS
}

func (MigrationFS) Glob

func (m MigrationFS) Glob(pattern string) (matches []string, fault error)

func (MigrationFS) Open

func (m MigrationFS) Open(name string) (file fs.File, fault error)

func (MigrationFS) ReadDir

func (m MigrationFS) ReadDir(name string) ([]fs.FileInfo, error)

func (MigrationFS) ReadFile

func (m MigrationFS) ReadFile(name string) (contents []byte, fault error)

type MigrationInfo

type MigrationInfo struct {
	CurrentVersion int32
	TargetVersion  int32
	Stages         []Stage
	Summary        string
}

type Querier

type Querier interface {
	GetAPIRequests(ctx context.Context) (RemoteApiRequest, error)
	StoreAPIRequest(ctx context.Context, arg StoreAPIRequestParams) error
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GetAPIRequests

func (q *Queries) GetAPIRequests(ctx context.Context) (RemoteApiRequest, error)

func (*Queries) StoreAPIRequest

func (q *Queries) StoreAPIRequest(ctx context.Context, arg StoreAPIRequestParams) error

func (*Queries) WithTx

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

type RemoteApiRequest

type RemoteApiRequest struct {
	Id              int32              `db:"id" json:"id"`
	Url             string             `db:"url" json:"url"`
	Method          string             `db:"method" json:"method"`
	RequestHeaders  []byte             `db:"request_headers" json:"request_headers"`
	RequestBody     pgtype.Text        `db:"request_body" json:"request_body"`
	ResponseTimeMs  int64              `db:"response_time_ms" json:"response_time_ms"`
	ResponseHeaders []byte             `db:"response_headers" json:"response_headers"`
	ResponseBody    pgtype.Text        `db:"response_body" json:"response_body"`
	StatusCode      int32              `db:"status_code" json:"status_code"`
	CreatedAt       pgtype.Timestamptz `db:"created_at" json:"created_at"`
}

type Stage

type Stage struct {
	Sequence int32
	Name     string
	Migrated bool
}

type StoreAPIRequestParams

type StoreAPIRequestParams struct {
	Url             string      `db:"url" json:"url"`
	Method          string      `db:"method" json:"method"`
	RequestHeaders  []byte      `db:"request_headers" json:"request_headers"`
	RequestBody     pgtype.Text `db:"request_body" json:"request_body"`
	ResponseTimeMs  int64       `db:"response_time_ms" json:"response_time_ms"`
	ResponseHeaders []byte      `db:"response_headers" json:"response_headers"`
	ResponseBody    pgtype.Text `db:"response_body" json:"response_body"`
	StatusCode      int32       `db:"status_code" json:"status_code"`
}

Jump to

Keyboard shortcuts

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