runner

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MissingParameterErrorText = "missing parameter"
)
View Source
const ReadmeFile = "README.md"

ReadmeFile is the location we look for to extract documentation from template versions.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobUpdater

type JobUpdater interface {
	UpdateJob(ctx context.Context, in *proto.UpdateJobRequest) (*proto.UpdateJobResponse, error)
	FailJob(ctx context.Context, in *proto.FailedJob) error
	CompleteJob(ctx context.Context, in *proto.CompletedJob) error
}

type Runner

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

func NewRunner

func NewRunner(
	job *proto.AcquiredJob,
	updater JobUpdater,
	logger slog.Logger,
	filesystem afero.Fs,
	workDirectory string,
	provisioner sdkproto.DRPCProvisionerClient,
	updateInterval time.Duration,
	forceCancelInterval time.Duration) *Runner

func (*Runner) Cancel

func (r *Runner) Cancel()

Cancel initiates a Cancel on the job, but allows it to keep running to do so gracefully. Read from Done() to be notified when the job completes.

func (*Runner) Done

func (r *Runner) Done() <-chan any

func (*Runner) Fail

func (r *Runner) Fail(ctx context.Context, f *proto.FailedJob) error

Fail immediately halts updates and, if the job is not complete sends FailJob to the coder server. Running goroutines are canceled but complete asynchronously (although they are prevented from further updating the job to the coder server). The provided context sets how long to keep trying to send the FailJob.

func (*Runner) ForceStop

func (r *Runner) ForceStop()

ForceStop signals all goroutines to stop and prevents any further API calls back to coder server for this job

func (*Runner) Run

func (r *Runner) Run()

Run the job.

the idea here is to run two goroutines to work on the job: doCleanFinish and heartbeat, then use the `r.cond` to wait until the job is either complete or failed. This function then sends the complete or failed message --- the exception to this is if something calls Fail() on the Runner; either something external, like the server getting closed, or the heartbeat goroutine timing out after attempting to gracefully cancel. If something calls Fail(), then the failure is sent on that goroutine on the context passed into Fail(), and it marks okToSend false to signal us here that this function should not also send a terminal message.

Jump to

Keyboard shortcuts

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