task

package
v0.0.0-...-1aaec36 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 9 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 Function

type Function interface{}

Function is a pointer to the callback function

type FunctionMeta

type FunctionMeta struct {
	Name string
}

FunctionMeta holds information about function such as name and parameters.

func Translate

func Translate(function Function) (FunctionMeta, error)

type ID

type ID string

ID is returned upon scheduling a task to be executed

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      []string
	FuncManager config.FunctionManager
}

Task holds information about task

func New

func New(function FunctionMeta, params []string, funcManager config.FunctionManager) *Task

New returns an instance of task

func NewWithSchedule

func NewWithSchedule(function FunctionMeta, params []string, schedule Schedule, funcManager config.FunctionManager) *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.

func (*Task) ScheduleNextRun

func (task *Task) ScheduleNextRun()

Jump to

Keyboard shortcuts

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