Documentation
¶
Index ¶
- Constants
- type Engine
- func (e *Engine) CountWorkers(ctx context.Context) (int64, error)
- func (e *Engine) CreateWorker(ctx context.Context, w *api.Worker) (*api.Worker, error)
- func (e *Engine) CreateWorkerIndexes(ctx context.Context) error
- func (e *Engine) CreateWorkerTable(ctx context.Context, driver string) error
- func (e *Engine) DeleteWorker(ctx context.Context, w *api.Worker) error
- func (e *Engine) GetWorker(ctx context.Context, id int64) (*api.Worker, error)
- func (e *Engine) GetWorkerForHostname(ctx context.Context, hostname string) (*api.Worker, error)
- func (e *Engine) ListWorkers(ctx context.Context, active string, before, after int64) ([]*api.Worker, error)
- func (e *Engine) UpdateWorker(ctx context.Context, w *api.Worker) (*api.Worker, error)
- type EngineOpt
- type WorkerInterface
Constants ¶
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 */ )
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 (*Engine) CountWorkers ¶ added in v0.27.0
CountWorkers gets the count of all workers from the database.
func (*Engine) CreateWorker ¶ added in v0.27.0
CreateWorker creates a new worker in the database.
func (*Engine) CreateWorkerIndexes ¶ added in v0.27.0
CreateWorkerIndexes creates the indexes for the workers table in the database.
func (*Engine) CreateWorkerTable ¶ added in v0.27.0
CreateWorkerTable creates the workers table in the database.
func (*Engine) DeleteWorker ¶ added in v0.27.0
DeleteWorker deletes an existing worker from the database.
func (*Engine) GetWorkerForHostname ¶ added in v0.27.0
GetWorkerForHostname gets a worker by hostname from the database.
type EngineOpt ¶
EngineOpt represents a configuration option to initialize the database engine for Workers.
func WithClient ¶
WithClient sets the gorm.io/gorm client in the database engine for Workers.
func WithContext ¶ added in v0.21.0
WithContext sets the context in the database engine for Workers.
func WithLogger ¶
WithLogger sets the github.com/sirupsen/logrus logger in the database engine for Workers.
func WithSkipCreation ¶
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)
}