Documentation
¶
Overview ¶
Package capacitor provides a configurable delay for a series of function calls. A capacitor is discharged when it is time to actually invoke the target function.
Index ¶
Constants ¶
View Source
const DefaultDelay time.Duration = time.Second
DefaultDelay is the default time a capacitor waits to execute the most recently submitted function
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
// Submit submits a function for execution. The function will not be executed immediately.
// Instead, after a configurable period of time, the most recent function passed to Submit will
// be executed. The previous ones are ignored.
Submit(func())
// Discharge forcibly discharges this capacitor. The most recent function passed to Submit is
// executed, and the internal state is reset so that the next call to Submit will start the
// process of delaying function calls all over again.
Discharge()
// Cancel terminates any waiting function call without executing it. As with Discharge, the
// internal state is reset so that Submit calls will delay functions as normal again.
Cancel()
}
Interface represents a capacitor of function calls which will discharge after a configurable period of time.
Click to show internal directories.
Click to hide internal directories.