Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultBackoffResetDuration = time.Minute DefaultBackoffJitter = 0.1 )
Values for DefaultBackoffConfig.
Variables ¶
View Source
var ( // DefaultBackoffIntervals are the default task backoff intervals. DefaultBackoffIntervals = [...]time.Duration{ 10 * time.Millisecond, 50 * time.Millisecond, 100 * time.Millisecond, time.Second, } // DefaultBackoffIntervalFunc is the default BackoffIntervalFunc. DefaultBackoffIntervalFunc = MakeBackoffIntervalFunc(false, DefaultBackoffResetDuration, DefaultBackoffIntervals[:]...) // DefaultBackoffConfig is the default task backoff config. DefaultBackoffConfig = &BackoffConfig{ Jitter: DefaultBackoffJitter, IntervalFunc: DefaultBackoffIntervalFunc, } // DialBackoffIntervals are the default task backoff intervals for tasks using Dial. DialBackoffIntervals = [...]time.Duration{ 100 * time.Millisecond, time.Second, 10 * time.Second, } // DialBackoffIntervalFunc is the default BackoffIntervalFunc for tasks using Dial. DialBackoffIntervalFunc = MakeBackoffIntervalFunc(false, DefaultBackoffResetDuration, DialBackoffIntervals[:]...) // DialBackoffConfig is the default task backoff config for tasks using Dial. DialBackoffConfig = &BackoffConfig{ Jitter: DefaultBackoffJitter, IntervalFunc: DialBackoffIntervalFunc, } )
Functions ¶
func DefaultStartTask ¶
func DefaultStartTask(conf *Config)
DefaultStartTask is the default TaskStarter.
Types ¶
type BackoffConfig ¶
type BackoffConfig struct { Jitter float64 IntervalFunc BackoffIntervalFunc }
BackoffConfig represents task backoff configuration.
type BackoffIntervalFunc ¶
type BackoffIntervalFunc func(ctx context.Context, executionDuration time.Duration, invocation uint, err error) time.Duration
BackoffIntervalFunc is a function that decides the backoff interval based on the attempt history. invocation is a counter, which starts at 1 and is incremented after each task function invocation.
func MakeBackoffIntervalFunc ¶
func MakeBackoffIntervalFunc(onFailure bool, resetDuration time.Duration, intervals ...time.Duration) BackoffIntervalFunc
MakeBackoffIntervalFunc returns a new BackoffIntervalFunc.
type Config ¶
type Config struct { Context context.Context ID string Func Func Done func() Restart Restart Backoff *BackoffConfig }
Config represents task configuration.
type Restart ¶
type Restart uint8
Restart defines a task's restart policy.
const ( // RestartNever denotes a restart policy that never restarts tasks after success or failure. RestartNever Restart = iota // RestartAlways denotes a restart policy that always restarts tasks, on success and failure. RestartAlways // RestartOnFailure denotes a restart policy that restarts tasks on failure. RestartOnFailure )
type StartTaskFunc ¶
type StartTaskFunc func(*Config)
StartTaskFunc is a function that implements the TaskStarter interface.
func (StartTaskFunc) StartTask ¶
func (f StartTaskFunc) StartTask(conf *Config)
StartTask implements the TaskStarter interface.
Click to show internal directories.
Click to hide internal directories.