Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidOffset = errors.New("offset must be in [0, 86400000)") ErrNilFunction = errors.New("function cannot be nil") )
Functions ¶
This section is empty.
Types ¶
type RollingOnce ¶
type RollingOnce struct {
// contains filtered or unexported fields
}
RollingOnce 实现基于时间窗口的周期性任务懒加载 默认每天在指定偏移时间(如9:00)重置状态,允许再次执行任务
func NewRollingOnce ¶
func NewRollingOnce(windowMs, offsetMs int64, task func()) (*RollingOnce, error)
NewRollingOnce 创建新的RollingOnce实例 参数说明:
windowMs - 窗口持续时间(毫秒),建议 >= 1000 offsetMs - 每日偏移量(毫秒),范围 [0, 86400000) task - 要执行的任务函数
func NewRollingOnceWithHourAndMinute ¶ added in v1.22.9
func NewRollingOnceWithHourAndMinute(hour, minute int, task func()) (*RollingOnce, error)
NewRollingOnceWithHourAndMinute 创建指定时分的每日初始化RollingOnce实例
func (*RollingOnce) AdjustOffset ¶
func (o *RollingOnce) AdjustOffset(newOffsetMs int64) error
AdjustOffset 动态调整时间偏移量(线程安全)
Click to show internal directories.
Click to hide internal directories.