routine

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithClock

func WithClock(c clock.Clock) interface {
	RecurringTaskOption
	DelayTaskOption
}

WithClock set a clock to a task.

Types

type DelayTask

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

DelayTask represents a timeout task

func NewDelayTask

func NewDelayTask(cb Task, d time.Duration, ops ...DelayTaskOption) *DelayTask

NewDelayTask creates an instance of DelayTask

func (*DelayTask) Start

func (t *DelayTask) Start(ctx context.Context) error

Start executes the delayed task after given timeout.

func (*DelayTask) Stop

func (t *DelayTask) Stop(ctx context.Context) error

Stop stops the timeout

type DelayTaskOption

type DelayTaskOption interface {
	SetDelayTaskOption(*DelayTask)
}

DelayTaskOption is option to DelayTask.

type RecurringTask

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

RecurringTask represents a recurring task

func NewRecurringTask

func NewRecurringTask(t Task, i time.Duration, ops ...RecurringTaskOption) *RecurringTask

NewRecurringTask creates an instance of RecurringTask

func (*RecurringTask) Start

func (t *RecurringTask) Start(ctx context.Context) error

Start starts the timer

func (*RecurringTask) Stop

func (t *RecurringTask) Stop(_ context.Context) error

Stop stops the timer

type RecurringTaskOption

type RecurringTaskOption interface {
	SetRecurringTaskOption(*RecurringTask)
}

RecurringTaskOption is option to RecurringTask.

type Task

type Task func()

Task is the task logic to run.

Jump to

Keyboard shortcuts

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