worker
v1.1.1
Documentation
pkg.go.dev ↗Package worker contains the Worker implementation that is used for handling builds that are submitted to the server.
Types
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.
Runner.Collector
func (r *Runner) Collector() (runner.Collector, error)
Collector returns the configured runner.Collector implementation to use for collecting build artifacts.
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.
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.
Runner.Init
func (r *Runner) Init() error
Init initializes the underlying runner.Runner for build execution with the build data from the database.
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.
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.
Runner.Tail
func (r *Runner) Tail() string
Tail returns the last 15 lines of what was written to the runner's buffer.
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.
}
Worker.Run
func (w *Worker) Run(ctx context.Context) error
Run begins the worker for handling builds.
Worker.Runner
func (w *Worker) Runner(b *build.Build) *Runner
Runner configures a new runner for running the given build.