worker

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package worker contains the Worker implementation that is used for handling builds that are submitted to the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner

type Runner struct {
	runner.Runner
	// contains filtered or unexported fields
}

Runner is what's used for actually running the build retrieved from the worker. This will handle updating the state of the build and its jobs in the database whilst the build runs.

func (*Runner) Collector

func (r *Runner) Collector() (runner.Collector, error)

Collector returns the configured runner.Collector implementation to use for collecting build artifacts.

func (*Runner) DriverBuffer

func (r *Runner) DriverBuffer() *bytes.Buffer

DriverBuffer returns the buffer for the job that created the driver for the build's runner. If one cannot be found then nil is returned.

func (*Runner) DriverJob

func (r *Runner) DriverJob() *build.Job

DriverJob returns the build pseudo-job that was added to the build for tracking the progress of driver creation.

func (*Runner) Init

func (r *Runner) Init() error

Init initializes the underlying runner.Runner for build execution with the build data from the database.

func (*Runner) Placer

func (r *Runner) Placer() (runner.Placer, error)

Placer returns the configured runner.Placer implementation to use for placing build objects and keys into a build.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, jobId string, d *build.Driver) (runner.Status, error)

Run runs the build with the given driver. This will return the underlying status of the runner upon completion, along with any errors that may occur. If an underyling error does occur then the returned status will always be runner.Failed.

func (*Runner) Tail

func (r *Runner) Tail() string

Tail returns the last 15 lines of what was written to the runner's buffer.

type Worker

type Worker struct {
	// DB is the client to the SQL database.
	DB *sqlx.DB

	// Redis is the client to the Redis database from where submitted builds
	// will be processed from.
	Redis *redis.Client

	// SMTP is the client to the SMTP server we use for sending emails about
	// a build's progress.
	SMTP *mail.Client

	// Admin is the email address that should be used in emails sent from the
	// worker on build failures.
	Admin string

	// Crypto is the block cipher to use for decrypting access tokens when
	// interacting with a provider's REST API.
	Crypto *crypto.AESGCM

	// Log is the logger implementation used for logging information about the
	// running builds.
	Log *log.Logger

	// Consumer is the consumer used for retrieving builds from the queue.
	Consumer *curlyq.Consumer

	Queue queue.Queue // Queue for dispatching webhooks.

	Driver  string        // Driver is the name of the driver the worker is configured for.
	Timeout time.Duration // Timeout is the maximum duration a build can run for.

	Init   driver.Init   // Init is the initialization function for the worker's driver.
	Config driver.Config // Config is the global configuration for the worker's driver.

	// Providers is the registry containing the provider client implementations
	// used for updating a build's commit status, if submitted via a pull
	// request hook.
	Providers *provider.Registry

	Objects   fs.Store // The fs.Store from where we place build objects.
	Artifacts fs.Store // The fs.Store to where we collect build artifacts.
}

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

Run begins the worker for handling builds.

func (*Worker) Runner

func (w *Worker) Runner(b *build.Build) *Runner

Runner configures a new runner for running the given build.

Jump to

Keyboard shortcuts

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