async

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 4 Imported by: 14

README

Async

Placeholder

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// RegisterJob registers a new Job with the async engine
	RegisterJob(name string, fn JobFn) error
	// SubmitTask submits an idempotent task to the async engine for reliable,
	// asynchronous completion
	SubmitTask(Task) error
	// Run causes the async engine to carry out all of its functions. It blocks
	// until a fatal error is encountered or the context passed to it has been
	// canceled. Run always returns a non-nil error.
	Run(context.Context) error
}

Engine is an interface for a broker-specifc framework for submitting and asynchronously completing provisioning and deprovisioning tasks.

type JobFn

type JobFn func(ctx context.Context, task Task) ([]Task, error)

JobFn is the signature for functions that workers can call to asynchronously execute a job

type Task

type Task interface {
	GetID() string
	GetJobName() string
	GetArgs() map[string]string
	GetWorkerRejectionCount() int
	IncrementWorkerRejectionCount() int
	ToJSON() ([]byte, error)
	GetExecuteTime() *time.Time
}

Task is an interface to be implemented by types that represent a single asynchronous task

func NewDelayedTask

func NewDelayedTask(
	jobName string,
	args map[string]string,
	delay time.Duration,
) Task

NewDelayedTask returns a new task that will fire after a specified duration

func NewScheduledTask

func NewScheduledTask(
	jobName string,
	args map[string]string,
	time time.Time,
) Task

NewScheduledTask returns a new task that will fire after a specified time

func NewTask

func NewTask(jobName string, args map[string]string) Task

NewTask returns a new task

func NewTaskFromJSON

func NewTaskFromJSON(jsonBytes []byte) (Task, error)

NewTaskFromJSON returns a new Task unmarshalled from the provided []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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