env

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 3 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	//The system context with cancel capability.
	SystemContext context.Context

	//Coordination signal
	WG *sync.WaitGroup

	//Report errors to bootstrap component
	//Once error is reported by lower components, the whole system should exit
	ErrorChan chan error

	//The base job context reference
	//It will be the parent conetext of job execution context
	JobContext JobContext
}

Context keep some sharable materials and system controling channels. The system context.Context interface is also included.

type JobContext

type JobContext interface {
	//Build the context based on the parent context
	//
	//dep JobData : Dependencies for building the context, just in case that the build
	//function need some external info
	//
	//Returns:
	// new JobContext based on the parent one
	// error if meet any problems
	Build(dep JobData) (JobContext, error)

	//Get property from the context
	//
	//prop string : key of the context property
	//
	//Returns:
	//  The data of the specified context property if have
	//  bool to indicate if the property existing
	Get(prop string) (interface{}, bool)

	//SystemContext returns the system context
	//
	//Returns:
	//  context.Context
	SystemContext() context.Context

	//Checkin is bridge func for reporting detailed status
	//
	//status string : detailed status
	//
	//Returns:
	//  error if meet any problems
	Checkin(status string) error

	//OPCommand return the control operational command like stop/cancel if have
	//
	//Returns:
	//  op command if have
	//  flag to indicate if have command
	OPCommand() (string, bool)

	//Return the logger
	GetLogger() logger.Interface
}

JobContext is combination of BaseContext and other job specified resources. JobContext will be the real execution context for one job.

type JobContextInitializer

type JobContextInitializer func(ctx *Context) (JobContext, error)

JobContextInitializer is a func to initialize the concrete job context

type JobData

type JobData struct {
	ID        string
	Name      string
	Args      map[string]interface{}
	ExtraData map[string]interface{}
}

JobData defines job context dependencies.

Jump to

Keyboard shortcuts

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