control

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interval

func Interval(ctx context.Context, interval time.Duration, f func(), immediate ...bool)

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

func IntervalAt(ctx context.Context, start time.Time, interval time.Duration, f func())

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

func NewDebouncer(after time.Duration) func(f func())

NewDebouncer returns a debounced function that delays execution until after `after` duration has passed since the last call.

func NewThrottle

func NewThrottle(interval time.Duration) func(f func()) bool

NewThrottle returns a throttled function that ensures `f` is not executed more frequently than `interval`.

func NextDailyAt added in v0.6.0

func NextDailyAt(
	now time.Time,
	hour, minute, second int,
) time.Time

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

func NextMonthlyAt(
	now time.Time,
	day, hour, minute, second int,
) time.Time

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).

func NextWeeklyAt added in v0.6.1

func NextWeeklyAt(
	now time.Time,
	weekday time.Weekday,
	hour, minute, second int,
) time.Time

NextWeeklyAt calculates the next occurrence of a specific weekday and time.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL