Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Periodic ¶
type Periodic struct {
// Interval of the task being run
Interval time.Duration
// Execute is the task function
Execute func() error
// contains filtered or unexported fields
}
Periodic is a task that runs periodically.
type PeriodicTask ¶
type PeriodicTask struct {
Interval time.Duration // How often to run the task
// contains filtered or unexported fields
}
PeriodicTask is a struct that periodically runs a specified task
func NewPeriodicTask ¶
func NewPeriodicTask(interval time.Duration, task func() error, opts ...PeriodicTaskOption) *PeriodicTask
NewPeriodicTask creates a new PeriodicTask with the given interval and task
func (*PeriodicTask) Close ¶
func (pt *PeriodicTask) Close() error
Close stops the periodic task and waits for it to finish
func (*PeriodicTask) ResetInterval ¶
func (pt *PeriodicTask) ResetInterval(interval time.Duration)
func (*PeriodicTask) Start ¶
func (pt *PeriodicTask) Start() error
Start begins running the task periodically does not block
type PeriodicTaskOption ¶
type PeriodicTaskOption func(*PeriodicTask)
func WithStartImmediately ¶
func WithStartImmediately() PeriodicTaskOption
Click to show internal directories.
Click to hide internal directories.