Documentation
¶
Index ¶
- func Delay(wait time.Duration) error
- func DelayWithContext(ctx context.Context, wait time.Duration) error
- func For(condition func(int) (bool, error), timeout time.Duration, ...) (bool, error)
- func ForWithContext(ctx context.Context, condition func(context.Context, int) (bool, error), ...) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func For ¶
func For(condition func(int) (bool, error), timeout time.Duration, interval time.Duration) (bool, error)
等待,直到条件满足或超时。
入参:
- condition: 条件函数,接收尝试次数作为参数,返回是否满足条件和错误。
- timeout: 超时时间。
- interval: 执行条件函数的间隔时间。
出参:
- ret: 是否满足条件。
- err: 错误。
func ForWithContext ¶
func ForWithContext(ctx context.Context, condition func(context.Context, int) (bool, error), timeout time.Duration, interval time.Duration) (bool, error)
等待,直到条件满足或超时,或上下文被取消。
入参:
- ctx: 上下文。
- condition: 条件函数,接收上下文和尝试次数作为参数,返回是否满足条件和错误。
- timeout: 超时时间。
- interval: 执行条件函数的间隔时间。
出参:
- ret: 是否满足条件。
- err: 错误。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.