Documentation
¶
Index ¶
- func Interval(ctx context.Context, interval time.Duration, f func(), immediate ...bool)
- func IntervalAt(ctx context.Context, start time.Time, interval time.Duration, f func())
- func NewDebouncer(after time.Duration) func(f func())
- func NewThrottle(interval time.Duration) func(f func()) bool
- func NextDailyAt(now time.Time, hour, minute, second int) time.Time
- func NextMonthlyAt(now time.Time, day, hour, minute, second int) time.Time
- func NextWeeklyAt(now time.Time, weekday time.Weekday, hour, minute, second int) time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Interval ¶
Interval calls `f` at regular `interval` until the `ctx` is cancelled. If `immediate` is true, `f` is called once at the beginning without waiting for the first tick.
func IntervalAt ¶ added in v0.6.0
IntervalAt calls `f` starting at `start` time and then every `interval` until `ctx` is cancelled. If `start` is in the past, `f` is executed immediately.
func NewDebouncer ¶
NewDebouncer returns a debounced function that delays execution until after `after` duration has passed since the last call.
func NewThrottle ¶
NewThrottle returns a throttled function that ensures `f` is not executed more frequently than `interval`.
func NextDailyAt ¶ added in v0.6.0
NextDailyAt calculates the next occurrence of a specific time (hour, minute, second). It respects the time zone (Location) of the provided 'now' time.
func NextMonthlyAt ¶ added in v0.6.1
NextMonthlyAt calculates the next occurrence of a specific day of the month and time. Note: If the day exceeds the days in the target month (e.g. 31st of February), standard Go time normalization applies (e.g., March 3rd).
Types ¶
This section is empty.