routine

package
v2.1.0-rc17 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

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 {
	lifecycle.Readiness
	// 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(_ 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