task

package
v0.0.0-...-e816cb4 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackMock

type CallbackMock struct {
	mock.Mock
}

CallbackMock is used for testing Task

func (*CallbackMock) CallNoArgs

func (m *CallbackMock) CallNoArgs()

CallNoArgs is a dummy function which accepts no arguments

func (*CallbackMock) CallWithArgs

func (m *CallbackMock) CallWithArgs(arg1 string, arg2 bool)

CallWithArgs is a dummy function which accepts two arguments

func (*CallbackMock) CallWithChan

func (m *CallbackMock) CallWithChan(channel chan bool)

CallWithChan is a dummy function to test failure with non-hashable parameters

type FuncRegistry

type FuncRegistry struct {
	// contains filtered or unexported fields
}

FuncRegistry holds the list of all registered task functions.

func NewFuncRegistry

func NewFuncRegistry() *FuncRegistry

NewFuncRegistry will return an instance of the FuncRegistry.

func (*FuncRegistry) Add

func (reg *FuncRegistry) Add(function Function) (FunctionMeta, error)

Add appends the function to the registry after resolving specific information about this function.

func (*FuncRegistry) Exists

func (reg *FuncRegistry) Exists(name string) bool

Exists checks if a function with provided name exists.

func (*FuncRegistry) Get

func (reg *FuncRegistry) Get(name string) (FunctionMeta, error)

Get returns the FunctionMeta instance which holds all information about any single registered task function.

type Function

type Function interface{}

Function is a pointer to the callback function

type FunctionMeta

type FunctionMeta struct {
	Name string
	// contains filtered or unexported fields
}

FunctionMeta holds information about function such as name and parameters.

func (*FunctionMeta) Params

func (meta *FunctionMeta) Params() []reflect.Type

Params returns the list of parameter types

type ID

type ID string

ID is returned upon scheduling a task to be executed

type Param

type Param interface{}

Param represents a single function parameter

type Schedule

type Schedule struct {
	IsRecurring bool
	LastRun     time.Time
	NextRun     time.Time
	Duration    time.Duration
}

Schedule holds information about the execution times of a specific task

type Task

type Task struct {
	Schedule
	Func   FunctionMeta
	Params []Param
}

Task holds information about task

func New

func New(function FunctionMeta, params []Param) *Task

New returns an instance of task

func NewWithSchedule

func NewWithSchedule(function FunctionMeta, params []Param, schedule Schedule) *Task

NewWithSchedule creates an instance of task with the provided schedule information

func (*Task) Hash

func (task *Task) Hash() ID

Hash will return the SHA1 representation of the task's data.

func (*Task) IsDue

func (task *Task) IsDue() bool

IsDue returns a boolean indicating whether the task should execute or not

func (*Task) Run

func (task *Task) Run()

Run will execute the task and schedule it's next run.

Jump to

Keyboard shortcuts

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