models

package
v0.0.0-...-1dd44bc Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareAllQueries

func PrepareAllQueries(ctx context.Context, p preparer) error

PrepareAllQueries executes a PREPARE statement for all pggen generated SQL queries in querier files. Typical usage is as the AfterConnect callback for pgxpool.Config

pgx will use the prepared statement if available. Calling PrepareAllQueries is an optional optimization to avoid a network round-trip the first time pgx runs a query if pgx statement caching is enabled.

Types

type DBQuerier

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

func NewQuerier

func NewQuerier(conn genericConn) *DBQuerier

NewQuerier creates a DBQuerier that implements Querier. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.

func NewQuerierConfig

func NewQuerierConfig(conn genericConn, cfg QuerierConfig) *DBQuerier

NewQuerierConfig creates a DBQuerier that implements Querier with the given config. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.

func (*DBQuerier) GetContainersForSchedule

func (q *DBQuerier) GetContainersForSchedule(ctx context.Context, scheduleID uuid.UUID) ([]GetContainersForScheduleRow, error)

GetContainersForSchedule implements Querier.GetContainersForSchedule.

func (*DBQuerier) GetContainersForScheduleBatch

func (q *DBQuerier) GetContainersForScheduleBatch(batch genericBatch, scheduleID uuid.UUID)

GetContainersForScheduleBatch implements Querier.GetContainersForScheduleBatch.

func (*DBQuerier) GetContainersForScheduleScan

func (q *DBQuerier) GetContainersForScheduleScan(results pgx.BatchResults) ([]GetContainersForScheduleRow, error)

GetContainersForScheduleScan implements Querier.GetContainersForScheduleScan.

func (*DBQuerier) GetCurrentScheduleForDevice

func (q *DBQuerier) GetCurrentScheduleForDevice(ctx context.Context, deviceID uuid.UUID) (GetCurrentScheduleForDeviceRow, error)

GetCurrentScheduleForDevice implements Querier.GetCurrentScheduleForDevice.

func (*DBQuerier) GetCurrentScheduleForDeviceBatch

func (q *DBQuerier) GetCurrentScheduleForDeviceBatch(batch genericBatch, deviceID uuid.UUID)

GetCurrentScheduleForDeviceBatch implements Querier.GetCurrentScheduleForDeviceBatch.

func (*DBQuerier) GetCurrentScheduleForDeviceScan

func (q *DBQuerier) GetCurrentScheduleForDeviceScan(results pgx.BatchResults) (GetCurrentScheduleForDeviceRow, error)

GetCurrentScheduleForDeviceScan implements Querier.GetCurrentScheduleForDeviceScan.

func (*DBQuerier) GetDeviceByName

func (q *DBQuerier) GetDeviceByName(ctx context.Context, name *string) (GetDeviceByNameRow, error)

GetDeviceByName implements Querier.GetDeviceByName.

func (*DBQuerier) GetDeviceByNameBatch

func (q *DBQuerier) GetDeviceByNameBatch(batch genericBatch, name *string)

GetDeviceByNameBatch implements Querier.GetDeviceByNameBatch.

func (*DBQuerier) GetDeviceByNameScan

func (q *DBQuerier) GetDeviceByNameScan(results pgx.BatchResults) (GetDeviceByNameRow, error)

GetDeviceByNameScan implements Querier.GetDeviceByNameScan.

func (*DBQuerier) WithTx

func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)

WithTx creates a new DBQuerier that uses the transaction to run all queries.

type GetContainersForScheduleRow

type GetContainersForScheduleRow struct {
	ID               uuid.UUID  `json:"id"`
	CreatedAt        *time.Time `json:"created_at"`
	UpdatedAt        *time.Time `json:"updated_at"`
	Name             *string    `json:"name"`
	ContainerImage   *string    `json:"container_image"`
	Env              []byte     `json:"env"`
	Privileged       bool       `json:"privileged"`
	NetworkMode      *string    `json:"network_mode"`
	Ports            []byte     `json:"ports"`
	BindDev          bool       `json:"bind_dev"`
	BindProc         bool       `json:"bind_proc"`
	BindSys          bool       `json:"bind_sys"`
	BindShm          bool       `json:"bind_shm"`
	BindCgroup       bool       `json:"bind_cgroup"`
	BindDockerSocket bool       `json:"bind_docker_socket"`
	BindBoot         bool       `json:"bind_boot"`
	Command          *string    `json:"command"`
	Entrypoint       *string    `json:"entrypoint"`
	ScheduleID       uuid.UUID  `json:"schedule_id"`
}

type GetCurrentScheduleForDeviceRow

type GetCurrentScheduleForDeviceRow struct {
	ID        uuid.UUID  `json:"id"`
	Name      *string    `json:"name"`
	State     *string    `json:"state"`
	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

type GetDeviceByNameRow

type GetDeviceByNameRow struct {
	ID        uuid.UUID  `json:"id"`
	Name      *string    `json:"name"`
	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
	FleetID   uuid.UUID  `json:"fleet_id"`
}

type Querier

type Querier interface {
	GetCurrentScheduleForDevice(ctx context.Context, deviceID uuid.UUID) (GetCurrentScheduleForDeviceRow, error)
	// GetCurrentScheduleForDeviceBatch enqueues a GetCurrentScheduleForDevice query into batch to be executed
	// later by the batch.
	GetCurrentScheduleForDeviceBatch(batch genericBatch, deviceID uuid.UUID)
	// GetCurrentScheduleForDeviceScan scans the result of an executed GetCurrentScheduleForDeviceBatch query.
	GetCurrentScheduleForDeviceScan(results pgx.BatchResults) (GetCurrentScheduleForDeviceRow, error)

	GetContainersForSchedule(ctx context.Context, scheduleID uuid.UUID) ([]GetContainersForScheduleRow, error)
	// GetContainersForScheduleBatch enqueues a GetContainersForSchedule query into batch to be executed
	// later by the batch.
	GetContainersForScheduleBatch(batch genericBatch, scheduleID uuid.UUID)
	// GetContainersForScheduleScan scans the result of an executed GetContainersForScheduleBatch query.
	GetContainersForScheduleScan(results pgx.BatchResults) ([]GetContainersForScheduleRow, error)

	GetDeviceByName(ctx context.Context, name *string) (GetDeviceByNameRow, error)
	// GetDeviceByNameBatch enqueues a GetDeviceByName query into batch to be executed
	// later by the batch.
	GetDeviceByNameBatch(batch genericBatch, name *string)
	// GetDeviceByNameScan scans the result of an executed GetDeviceByNameBatch query.
	GetDeviceByNameScan(results pgx.BatchResults) (GetDeviceByNameRow, error)
}

Querier is a typesafe Go interface backed by SQL queries.

Methods ending with Batch enqueue a query to run later in a pgx.Batch. After calling SendBatch on pgx.Conn, pgxpool.Pool, or pgx.Tx, use the Scan methods to parse the results.

type QuerierConfig

type QuerierConfig struct {
	// DataTypes contains pgtype.Value to use for encoding and decoding instead
	// of pggen-generated pgtype.ValueTranscoder.
	//
	// If OIDs are available for an input parameter type and all of its
	// transitive dependencies, pggen will use the binary encoding format for
	// the input parameter.
	DataTypes []pgtype.DataType
}

Jump to

Keyboard shortcuts

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