worker

package
v0.27.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreatePostgresTable represents a query to create the Postgres workers table.
	CreatePostgresTable = `` /* 490-byte string literal not displayed */

	// CreateSqliteTable represents a query to create the Sqlite workers table.
	CreateSqliteTable = `` /* 481-byte string literal not displayed */

)
View Source
const (
	// CreateHostnameAddressIndex represents a query to create an
	// index on the workers table for the hostname and address columns.
	CreateHostnameAddressIndex = `
CREATE INDEX
IF NOT EXISTS
workers_hostname_address
ON workers (hostname, address);
`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine added in v0.27.0

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

Engine represents the worker functionality that implements the WorkerInterface interface.

func New

func New(opts ...EngineOpt) (*Engine, error)

New creates and returns a Vela service for integrating with workers in the database.

func (*Engine) CountWorkers added in v0.27.0

func (e *Engine) CountWorkers(ctx context.Context) (int64, error)

CountWorkers gets the count of all workers from the database.

func (*Engine) CreateWorker added in v0.27.0

func (e *Engine) CreateWorker(ctx context.Context, w *api.Worker) (*api.Worker, error)

CreateWorker creates a new worker in the database.

func (*Engine) CreateWorkerIndexes added in v0.27.0

func (e *Engine) CreateWorkerIndexes(ctx context.Context) error

CreateWorkerIndexes creates the indexes for the workers table in the database.

func (*Engine) CreateWorkerTable added in v0.27.0

func (e *Engine) CreateWorkerTable(ctx context.Context, driver string) error

CreateWorkerTable creates the workers table in the database.

func (*Engine) DeleteWorker added in v0.27.0

func (e *Engine) DeleteWorker(ctx context.Context, w *api.Worker) error

DeleteWorker deletes an existing worker from the database.

func (*Engine) GetWorker added in v0.27.0

func (e *Engine) GetWorker(ctx context.Context, id int64) (*api.Worker, error)

GetWorker gets a worker by ID from the database.

func (*Engine) GetWorkerForHostname added in v0.27.0

func (e *Engine) GetWorkerForHostname(ctx context.Context, hostname string) (*api.Worker, error)

GetWorkerForHostname gets a worker by hostname from the database.

func (*Engine) ListWorkers added in v0.27.0

func (e *Engine) ListWorkers(ctx context.Context, active string, before, after int64) ([]*api.Worker, error)

ListWorkers gets a list of all workers from the database.

func (*Engine) UpdateWorker added in v0.27.0

func (e *Engine) UpdateWorker(ctx context.Context, w *api.Worker) (*api.Worker, error)

UpdateWorker updates an existing worker in the database.

type EngineOpt

type EngineOpt func(*Engine) error

EngineOpt represents a configuration option to initialize the database engine for Workers.

func WithClient

func WithClient(client *gorm.DB) EngineOpt

WithClient sets the gorm.io/gorm client in the database engine for Workers.

func WithContext added in v0.21.0

func WithContext(ctx context.Context) EngineOpt

WithContext sets the context in the database engine for Workers.

func WithLogger

func WithLogger(logger *logrus.Entry) EngineOpt

WithLogger sets the github.com/sirupsen/logrus logger in the database engine for Workers.

func WithSkipCreation

func WithSkipCreation(skipCreation bool) EngineOpt

WithSkipCreation sets the skip creation logic in the database engine for Workers.

type WorkerInterface added in v0.20.0

type WorkerInterface interface {

	// CreateWorkerIndexes defines a function that creates the indexes for the workers table.
	CreateWorkerIndexes(context.Context) error
	// CreateWorkerTable defines a function that creates the workers table.
	CreateWorkerTable(context.Context, string) error

	// CountWorkers defines a function that gets the count of all workers.
	CountWorkers(context.Context) (int64, error)
	// CreateWorker defines a function that creates a new worker.
	CreateWorker(context.Context, *api.Worker) (*api.Worker, error)
	// DeleteWorker defines a function that deletes an existing worker.
	DeleteWorker(context.Context, *api.Worker) error
	// GetWorker defines a function that gets a worker by ID.
	GetWorker(context.Context, int64) (*api.Worker, error)
	// GetWorkerForHostname defines a function that gets a worker by hostname.
	GetWorkerForHostname(context.Context, string) (*api.Worker, error)
	// ListWorkers defines a function that gets a list of all workers.
	ListWorkers(context.Context, string, int64, int64) ([]*api.Worker, error)
	// UpdateWorker defines a function that updates an existing worker.
	UpdateWorker(context.Context, *api.Worker) (*api.Worker, error)
}

Jump to

Keyboard shortcuts

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