action

package
v0.0.0-...-bc6c5c1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func(ctx context.Context) error

Action represents a cancelable unit of work

func (Action) Do

func (a Action) Do(ctx context.Context) error

Do provides a helper method to make action invocations more legible

func (Action) Use

func (a Action) Use(filters ...Filter) Action

Use creates a new actions that uses all the specified filters

type Filter

type Filter func(Action) Action

Filter provides a wrapper around an action

func Forever

func Forever(delay time.Duration) Filter

Forever repeats the target action forever until the context is canceled

func RestartBetween

func RestartBetween(from, to timeofday.Clock, delay time.Duration) Filter

RestartBetween restarts the action after a delay as long as the time is within the time range provided. Only the hour, minute, and second

func Retry

func Retry(retries int, delay time.Duration) Filter

Retry failed retries up to the specified number of times

func Singleton

func Singleton(heartbeat Heartbeat, opts ...SingletonOption) Filter

Singleton takes an instance and ensure that only a single instance of it will run

func StopAfter

func StopAfter(d time.Duration) Filter

StopAfter stops an action after the specified period of time has elapsed

func (Filter) AndThen

func (f Filter) AndThen(a Action) Action

AndThen returns an action that executes the filter first and then the target Action

type Heartbeat

type Heartbeat interface {
	Publish(tick Tick) error
	Receive(ctx context.Context) (<-chan Tick, error)
}

type SingletonOption

type SingletonOption func(*singleton)

func WithElections

func WithElections(d time.Duration) SingletonOption

func WithInterval

func WithInterval(d time.Duration) SingletonOption

func WithLease

func WithLease(d time.Duration) SingletonOption

type Tick

type Tick struct {
	ID        string
	StartedAt time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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