pg

package
v0.0.0-...-e89cace Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, connString string) (*pgxpool.Pool, error)

Connect creates a pgx connection pool and runs migrations.

func MigrateTo

func MigrateTo(pool *pgxpool.Pool, version int64) error

MigrateTo runs embedded migrations up to and including version on an existing pool. Exposed so migration tests can stop partway, seed data, then continue.

Types

type Batch

type Batch struct {
	ID               int64              `json:"id"`
	RepoID           int64              `json:"repo_id"`
	TargetBranch     string             `json:"target_branch"`
	State            BatchState         `json:"state"`
	MemberIds        []int64            `json:"member_ids"`
	CurrentIds       []int64            `json:"current_ids"`
	Pending          []byte             `json:"pending"`
	LandedIds        []int64            `json:"landed_ids"`
	EjectedIds       []int64            `json:"ejected_ids"`
	BranchName       pgtype.Text        `json:"branch_name"`
	BranchSha        pgtype.Text        `json:"branch_sha"`
	Builds           int32              `json:"builds"`
	FfRetries        int32              `json:"ff_retries"`
	Flaky            bool               `json:"flaky"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	TestingStartedAt pgtype.Timestamptz `json:"testing_started_at"`
}

type BatchState

type BatchState string
const (
	BatchStateForming   BatchState = "forming"
	BatchStateTesting   BatchState = "testing"
	BatchStateDone      BatchState = "done"
	BatchStateCancelled BatchState = "cancelled"
)

func (*BatchState) Scan

func (e *BatchState) Scan(src interface{}) error

type CheckState

type CheckState string
const (
	CheckStatePending CheckState = "pending"
	CheckStateSuccess CheckState = "success"
	CheckStateFailure CheckState = "failure"
	CheckStateError   CheckState = "error"
)

func (*CheckState) Scan

func (e *CheckState) Scan(src interface{}) error

type CheckStatus

type CheckStatus struct {
	ID           int64              `json:"id"`
	QueueEntryID int64              `json:"queue_entry_id"`
	Context      string             `json:"context"`
	State        CheckState         `json:"state"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
	TargetUrl    string             `json:"target_url"`
}

type CountQueuePositionParams

type CountQueuePositionParams struct {
	RepoID       int64  `json:"repo_id"`
	TargetBranch string `json:"target_branch"`
	PrNumber     int64  `json:"pr_number"`
}

type CreateBatchParams

type CreateBatchParams struct {
	RepoID       int64   `json:"repo_id"`
	TargetBranch string  `json:"target_branch"`
	MemberIds    []int64 `json:"member_ids"`
}

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 DequeuePRParams

type DequeuePRParams struct {
	RepoID   int64 `json:"repo_id"`
	PrNumber int64 `json:"pr_number"`
}

type EnqueuePRParams

type EnqueuePRParams struct {
	RepoID       int64  `json:"repo_id"`
	PrNumber     int64  `json:"pr_number"`
	PrHeadSha    string `json:"pr_head_sha"`
	TargetBranch string `json:"target_branch"`
}

type EntryState

type EntryState string
const (
	EntryStateQueued    EntryState = "queued"
	EntryStateTesting   EntryState = "testing"
	EntryStateSuccess   EntryState = "success"
	EntryStateFailed    EntryState = "failed"
	EntryStateCancelled EntryState = "cancelled"
)

func (*EntryState) Scan

func (e *EntryState) Scan(src interface{}) error

type GetHeadOfQueueParams

type GetHeadOfQueueParams struct {
	RepoID       int64  `json:"repo_id"`
	TargetBranch string `json:"target_branch"`
}

type GetLiveBatchParams

type GetLiveBatchParams struct {
	RepoID       int64  `json:"repo_id"`
	TargetBranch string `json:"target_branch"`
}

type GetOrCreateRepoParams

type GetOrCreateRepoParams struct {
	Forge string `json:"forge"`
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

type GetQueueEntryParams

type GetQueueEntryParams struct {
	RepoID   int64 `json:"repo_id"`
	PrNumber int64 `json:"pr_number"`
}

type ListQueueParams

type ListQueueParams struct {
	RepoID       int64  `json:"repo_id"`
	TargetBranch string `json:"target_branch"`
}

type LoadActiveQueuesRow

type LoadActiveQueuesRow struct {
	ID               int64              `json:"id"`
	RepoID           int64              `json:"repo_id"`
	PrNumber         int64              `json:"pr_number"`
	PrHeadSha        string             `json:"pr_head_sha"`
	TargetBranch     string             `json:"target_branch"`
	State            EntryState         `json:"state"`
	EnqueuedAt       pgtype.Timestamptz `json:"enqueued_at"`
	TestingStartedAt pgtype.Timestamptz `json:"testing_started_at"`
	CompletedAt      pgtype.Timestamptz `json:"completed_at"`
	MergeBranchName  pgtype.Text        `json:"merge_branch_name"`
	MergeBranchSha   pgtype.Text        `json:"merge_branch_sha"`
	ErrorMessage     pgtype.Text        `json:"error_message"`
	ActiveBatchID    pgtype.Int8        `json:"active_batch_id"`
	Forge            string             `json:"forge"`
	Owner            string             `json:"owner"`
	RepoName         string             `json:"repo_name"`
}

type NullBatchState

type NullBatchState struct {
	BatchState BatchState `json:"batch_state"`
	Valid      bool       `json:"valid"` // Valid is true if BatchState is not NULL
}

func (*NullBatchState) Scan

func (ns *NullBatchState) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullBatchState) Value

func (ns NullBatchState) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullCheckState

type NullCheckState struct {
	CheckState CheckState `json:"check_state"`
	Valid      bool       `json:"valid"` // Valid is true if CheckState is not NULL
}

func (*NullCheckState) Scan

func (ns *NullCheckState) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullCheckState) Value

func (ns NullCheckState) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullEntryState

type NullEntryState struct {
	EntryState EntryState `json:"entry_state"`
	Valid      bool       `json:"valid"` // Valid is true if EntryState is not NULL
}

func (*NullEntryState) Scan

func (ns *NullEntryState) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullEntryState) Value

func (ns NullEntryState) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CancelBatchesByRepo

func (q *Queries) CancelBatchesByRepo(ctx context.Context, repoID int64) error

func (*Queries) ClearCheckStatuses

func (q *Queries) ClearCheckStatuses(ctx context.Context, ids []int64) error

func (*Queries) ClearEntryMergeBranch

func (q *Queries) ClearEntryMergeBranch(ctx context.Context, ids []int64) error

func (*Queries) CountQueuePosition

func (q *Queries) CountQueuePosition(ctx context.Context, arg CountQueuePositionParams) (int64, error)

func (*Queries) CreateBatch

func (q *Queries) CreateBatch(ctx context.Context, arg CreateBatchParams) (Batch, error)

func (*Queries) DeleteEntriesByIDs

func (q *Queries) DeleteEntriesByIDs(ctx context.Context, ids []int64) error

func (*Queries) DequeueAllByRepo

func (q *Queries) DequeueAllByRepo(ctx context.Context, repoID int64) error

func (*Queries) DequeuePR

func (q *Queries) DequeuePR(ctx context.Context, arg DequeuePRParams) error

func (*Queries) EnqueuePR

func (q *Queries) EnqueuePR(ctx context.Context, arg EnqueuePRParams) (QueueEntry, error)

func (*Queries) GetBatch

func (q *Queries) GetBatch(ctx context.Context, id int64) (Batch, error)

func (*Queries) GetCheckStatuses

func (q *Queries) GetCheckStatuses(ctx context.Context, queueEntryID int64) ([]CheckStatus, error)

func (*Queries) GetEntriesByIDs

func (q *Queries) GetEntriesByIDs(ctx context.Context, ids []int64) ([]QueueEntry, error)

func (*Queries) GetHeadOfQueue

func (q *Queries) GetHeadOfQueue(ctx context.Context, arg GetHeadOfQueueParams) (QueueEntry, error)

func (*Queries) GetLiveBatch

func (q *Queries) GetLiveBatch(ctx context.Context, arg GetLiveBatchParams) (Batch, error)

func (*Queries) GetOrCreateRepo

func (q *Queries) GetOrCreateRepo(ctx context.Context, arg GetOrCreateRepoParams) (Repo, error)

func (*Queries) GetQueueEntry

func (q *Queries) GetQueueEntry(ctx context.Context, arg GetQueueEntryParams) (QueueEntry, error)

func (*Queries) ListActiveEntriesByRepo

func (q *Queries) ListActiveEntriesByRepo(ctx context.Context, repoID int64) ([]QueueEntry, error)

func (*Queries) ListLiveBatchesByRepo

func (q *Queries) ListLiveBatchesByRepo(ctx context.Context, repoID int64) ([]Batch, error)

func (*Queries) ListQueue

func (q *Queries) ListQueue(ctx context.Context, arg ListQueueParams) ([]QueueEntry, error)

func (*Queries) LoadActiveQueues

func (q *Queries) LoadActiveQueues(ctx context.Context) ([]LoadActiveQueuesRow, error)

func (*Queries) SaveBatch

func (q *Queries) SaveBatch(ctx context.Context, arg SaveBatchParams) (Batch, error)

func (*Queries) SaveCheckStatus

func (q *Queries) SaveCheckStatus(ctx context.Context, arg SaveCheckStatusParams) error

func (*Queries) SetEntryActiveBatch

func (q *Queries) SetEntryActiveBatch(ctx context.Context, arg SetEntryActiveBatchParams) error

func (*Queries) TakeQueuedHead

func (q *Queries) TakeQueuedHead(ctx context.Context, arg TakeQueuedHeadParams) ([]QueueEntry, error)

func (*Queries) UpdateEntryError

func (q *Queries) UpdateEntryError(ctx context.Context, arg UpdateEntryErrorParams) error

func (*Queries) UpdateEntryMergeBranch

func (q *Queries) UpdateEntryMergeBranch(ctx context.Context, arg UpdateEntryMergeBranchParams) error

func (*Queries) UpdateEntryState

func (q *Queries) UpdateEntryState(ctx context.Context, arg UpdateEntryStateParams) error

func (*Queries) WithTx

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

type QueueEntry

type QueueEntry struct {
	ID               int64              `json:"id"`
	RepoID           int64              `json:"repo_id"`
	PrNumber         int64              `json:"pr_number"`
	PrHeadSha        string             `json:"pr_head_sha"`
	TargetBranch     string             `json:"target_branch"`
	State            EntryState         `json:"state"`
	EnqueuedAt       pgtype.Timestamptz `json:"enqueued_at"`
	TestingStartedAt pgtype.Timestamptz `json:"testing_started_at"`
	CompletedAt      pgtype.Timestamptz `json:"completed_at"`
	MergeBranchName  pgtype.Text        `json:"merge_branch_name"`
	MergeBranchSha   pgtype.Text        `json:"merge_branch_sha"`
	ErrorMessage     pgtype.Text        `json:"error_message"`
	ActiveBatchID    pgtype.Int8        `json:"active_batch_id"`
}

type Repo

type Repo struct {
	ID        int64              `json:"id"`
	Owner     string             `json:"owner"`
	Name      string             `json:"name"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	Forge     string             `json:"forge"`
}

type SaveBatchParams

type SaveBatchParams struct {
	ID               int64              `json:"id"`
	State            BatchState         `json:"state"`
	CurrentIds       []int64            `json:"current_ids"`
	Pending          []byte             `json:"pending"`
	LandedIds        []int64            `json:"landed_ids"`
	EjectedIds       []int64            `json:"ejected_ids"`
	BranchName       pgtype.Text        `json:"branch_name"`
	BranchSha        pgtype.Text        `json:"branch_sha"`
	Builds           int32              `json:"builds"`
	FfRetries        int32              `json:"ff_retries"`
	Flaky            bool               `json:"flaky"`
	TestingStartedAt pgtype.Timestamptz `json:"testing_started_at"`
}

type SaveCheckStatusParams

type SaveCheckStatusParams struct {
	QueueEntryID int64      `json:"queue_entry_id"`
	Context      string     `json:"context"`
	State        CheckState `json:"state"`
	TargetUrl    string     `json:"target_url"`
}

type SetEntryActiveBatchParams

type SetEntryActiveBatchParams struct {
	ActiveBatchID pgtype.Int8 `json:"active_batch_id"`
	Ids           []int64     `json:"ids"`
}

type TakeQueuedHeadParams

type TakeQueuedHeadParams struct {
	RepoID       int64  `json:"repo_id"`
	TargetBranch string `json:"target_branch"`
	Limit        int32  `json:"limit"`
}

type UpdateEntryErrorParams

type UpdateEntryErrorParams struct {
	RepoID       int64       `json:"repo_id"`
	PrNumber     int64       `json:"pr_number"`
	ErrorMessage pgtype.Text `json:"error_message"`
}

type UpdateEntryMergeBranchParams

type UpdateEntryMergeBranchParams struct {
	RepoID          int64       `json:"repo_id"`
	PrNumber        int64       `json:"pr_number"`
	MergeBranchName pgtype.Text `json:"merge_branch_name"`
	MergeBranchSha  pgtype.Text `json:"merge_branch_sha"`
}

type UpdateEntryStateParams

type UpdateEntryStateParams struct {
	State    EntryState `json:"state"`
	RepoID   int64      `json:"repo_id"`
	PrNumber int64      `json:"pr_number"`
}

Jump to

Keyboard shortcuts

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