job

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RunContext

type RunContext struct {

	// Logger is sub-logger instance for the job
	Logger log.Logger

	// Context is context.Context instance for current job.
	Context context.Context

	// Error is job result channel
	Error chan error

	// RootVars used to hold variables of root context
	RootVars scope.Vars
	// contains filtered or unexported fields
}

RunContext used to store job state and communicate between task runner and job

func NewRunContext

func NewRunContext(parentCtx context.Context, rootVars scope.Vars, log log.Logger) *RunContext

NewRunContext creates a new job context instance

func (*RunContext) Cancel

func (r *RunContext) Cancel()

Cancel cancels the context and stops all jobs used by this context

func (*RunContext) ChildContext

func (r *RunContext) ChildContext() *RunContext

ChildContext creates a new child context with separate Error channel and context

func (*RunContext) ForkContext

func (r *RunContext) ForkContext() RunContext

ForkContext creates a context copy, but creates a separate sub-logger

func (*RunContext) IsAlive

func (r *RunContext) IsAlive() bool

IsAlive checks if context was not finished

func (*RunContext) IsChild

func (r *RunContext) IsChild() bool

IsChild checks if context is child context

func (*RunContext) Result

func (r *RunContext) Result(err error)

Result reports job result and finished the context

func (*RunContext) SetWaitGroup

func (r *RunContext) SetWaitGroup(wg *sync.WaitGroup)

SetWaitGroup sets wait group instance for current job

This value will be used later to call wg.Done() when job was finished.

func (*RunContext) Success

func (r *RunContext) Success()

Success reports successful result.

Alias to Result(nil)

func (*RunContext) Timeout

func (r *RunContext) Timeout(timeout time.Duration)

Timeout adds timeout to the context

Jump to

Keyboard shortcuts

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