db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountNodesPageParams

type CountNodesPageParams struct {
	Pattern    string             `json:"pattern"`
	State      string             `json:"state"`
	LostBefore pgtype.Timestamptz `json:"lost_before"`
	Stale      bool               `json:"stale"`
	Queues     []string           `json:"queues"`
	EncodeOnly bool               `json:"encode_only"`
}

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 ListNodesPageParams

type ListNodesPageParams struct {
	Pattern    string             `json:"pattern"`
	State      string             `json:"state"`
	LostBefore pgtype.Timestamptz `json:"lost_before"`
	Stale      bool               `json:"stale"`
	Queues     []string           `json:"queues"`
	EncodeOnly bool               `json:"encode_only"`
	AfterAt    pgtype.Timestamptz `json:"after_at"`
	AfterID    string             `json:"after_id"`
	Lim        int32              `json:"lim"`
}

type Node

type Node struct {
	ID               string             `json:"id"`
	Hostname         string             `json:"hostname"`
	Cpus             int32              `json:"cpus"`
	Queues           []string           `json:"queues"`
	Slots            []int32            `json:"slots"`
	Version          string             `json:"version"`
	Os               string             `json:"os"`
	Arch             string             `json:"arch"`
	MemoryBytes      pgtype.Int8        `json:"memory_bytes"`
	DiskBytes        pgtype.Int8        `json:"disk_bytes"`
	Ffmpeg           string             `json:"ffmpeg"`
	Gpu              string             `json:"gpu"`
	Encoders         []string           `json:"encoders"`
	Load1            pgtype.Float4      `json:"load1"`
	MemoryFreeBytes  pgtype.Int8        `json:"memory_free_bytes"`
	DiskFreeBytes    pgtype.Int8        `json:"disk_free_bytes"`
	StartedAt        pgtype.Timestamptz `json:"started_at"`
	LastSeenAt       pgtype.Timestamptz `json:"last_seen_at"`
	DrainRequestedAt pgtype.Timestamptz `json:"drain_requested_at"`
	StoppedAt        pgtype.Timestamptz `json:"stopped_at"`
}

type NodeHeartbeatParams

type NodeHeartbeatParams struct {
	Load1           pgtype.Float4 `json:"load1"`
	MemoryFreeBytes pgtype.Int8   `json:"memory_free_bytes"`
	DiskFreeBytes   pgtype.Int8   `json:"disk_free_bytes"`
	ID              string        `json:"id"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CountNodesPage

func (q *Queries) CountNodesPage(ctx context.Context, arg CountNodesPageParams) (int64, error)

func (*Queries) DeleteNode

func (q *Queries) DeleteNode(ctx context.Context, id string) (int64, error)

A node can be forgotten once it has stopped, or has been silent long enough to be presumed gone.

func (*Queries) ListNodes

func (q *Queries) ListNodes(ctx context.Context) ([]Node, error)

Every node, running ones first, newest start first.

func (*Queries) ListNodesPage

func (q *Queries) ListNodesPage(ctx context.Context, arg ListNodesPageParams) ([]Node, error)

Searches the host name and id, newest start first, continuing after the (after_at, after_id) row. lost_before is when a node counts as lost; stale keeps running nodes whose version isn't the newest running node's.

func (*Queries) NodeExists

func (q *Queries) NodeExists(ctx context.Context, id string) (bool, error)

func (*Queries) NodeHeartbeat

func (q *Queries) NodeHeartbeat(ctx context.Context, arg NodeHeartbeatParams) (pgtype.Timestamptz, error)

func (*Queries) RequestDrain

func (q *Queries) RequestDrain(ctx context.Context, id string) (int64, error)

func (*Queries) RetentionNodes

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

Nodes a week after they stopped or went silent.

func (*Queries) StopNode

func (q *Queries) StopNode(ctx context.Context, id string) error

func (*Queries) UpsertNode

func (q *Queries) UpsertNode(ctx context.Context, arg UpsertNodeParams) error

func (*Queries) WithTx

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

type UpsertNodeParams

type UpsertNodeParams struct {
	ID          string      `json:"id"`
	Hostname    string      `json:"hostname"`
	Cpus        int32       `json:"cpus"`
	Queues      []string    `json:"queues"`
	Slots       []int32     `json:"slots"`
	Version     string      `json:"version"`
	Os          string      `json:"os"`
	Arch        string      `json:"arch"`
	MemoryBytes pgtype.Int8 `json:"memory_bytes"`
	DiskBytes   pgtype.Int8 `json:"disk_bytes"`
	Ffmpeg      string      `json:"ffmpeg"`
	Gpu         string      `json:"gpu"`
	Encoders    []string    `json:"encoders"`
}

Jump to

Keyboard shortcuts

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