runner

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package runner implements running a job.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	Make(job proto.Job, requestId string) (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(key string, value Runner)
	Remove(key string)
	Items() (map[string]Runner, error)
}

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

func NewRepo

func NewRepo() Repo

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{}) byte

	// 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, 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