runner

package
v0.8.6-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package runner implements running a job.

Index

Constants

View Source
const (
	// Number of times to attempt sending a job log to the RM.
	JOB_LOG_TRIES = 3
	// Time to wait between attempts to send a job log to RM.
	JOB_LOG_RETRY_WAIT = 500 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	Make(job proto.Job, requestId string, prevTries uint, prevSeqTries uint, sequenceRetry uint) (Runner, error)
}

A Factory takes a proto.Job, creates a corresponding job.Job interface for it, and passes both to NewRunner to make a Runner.

func NewFactory

func NewFactory(jf job.Factory, rmc rm.Client) Factory

NewRunnerFactory makes a RunnerFactory.

type Repo

type Repo interface {
	Set(jobId string, runner Runner)
	Remove(jobId string)
	Items() (map[string]Runner, error)
	Count() int
}

Repo is a small wrapper around a concurrent map that provides the ability to store and retrieve Runners in a thread-safe way.

func NewRepo

func NewRepo() Repo

type Return

type Return struct {
	FinalState byte // Type of final status is.
	Tries      uint // Number of attempted tries in this run
}

type Runner

type Runner interface {
	// Run runs the job, blocking until it has completed or when Stop is called.
	// If the job fails, Run will retry it as many times as the job is configured
	// to be retried. After each run attempt, a Job Log is created and sent to
	// the RM. When the job successfully completes, or reaches the maximum number
	// of retry attempts, Run returns the final state of the job.
	Run(jobData map[string]interface{}) Return

	// Stop stops the job if it's running. The job is responsible for stopping
	// quickly because Stop blocks while waiting for the job to stop.
	Stop() error

	// Status returns the status of the job as reported by the job. The job
	// is responsible for handling status requests asynchronously while running.
	Status() string
}

A Runner runs and manages one job in a job chain. The job must implement the job.Job interface.

func NewRunner

func NewRunner(pJob proto.Job, realJob job.Job, reqId string, prevTryNo uint, sequenceTry uint, rmc rm.Client) Runner

NewRunner takes a proto.Job struct and its corresponding job.Job interface, and returns a Runner.

Jump to

Keyboard shortcuts

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