Documentation
¶
Index ¶
- Variables
- func BackoffUntil(ctx context.Context, f func(), backoff BackoffManager, sliding bool)
- func Forever(f func(), period time.Duration, sliding bool)
- func NonSlidingUntil(ctx context.Context, f func(), period time.Duration)
- func Until(ctx context.Context, f func(), period time.Duration)
- type BackoffManager
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NeverStop = context.TODO() NoThing = func() { return } )
Functions ¶
func BackoffUntil ¶
func BackoffUntil(ctx context.Context, f func(), backoff BackoffManager, sliding bool)
BackoffUntil 不断的运行 f 函数,运行间隔由BackoffManager 提供, 直到ctx.Done 返回. sliding 为true 则计算f函数运行时间.sliding 为false 则忽视f运行时间.
func NonSlidingUntil ¶
NonSlidingUntil 不断的以间隔period运行f, 直到ctx.Done 返回. 忽视f函数运行时间.
Types ¶
type BackoffManager ¶
BackoffManager 接口可以提供 Backoff 方法, Backoff 返回一个Timer 确定要等待的时间
func NewSimpleBackoffManager ¶
func NewSimpleBackoffManager(period time.Duration) BackoffManager
NewSimpleBackoffManager 返回一个简单的BackoffManager 以固定时间间隔返回Backoff
Click to show internal directories.
Click to hide internal directories.