Documentation ¶
Index ¶
- Variables
- type CycleCallback
- type CycleCallbackCtrl
- type CycleCallbackGroup
- type CycleIntervals
- func CompactionCycleIntervals() CycleIntervals
- func GeoCommitLoggerCycleIntervals() CycleIntervals
- func HnswCommitLoggerCycleIntervals() CycleIntervals
- func MemtableFlushCycleIntervals() CycleIntervals
- func NewExpIntervals(minInterval, maxInterval time.Duration, base, steps uint) CycleIntervals
- func NewFixedIntervals(interval time.Duration) CycleIntervals
- func NewLinearIntervals(minInterval, maxInterval time.Duration, steps uint) CycleIntervals
- func NewSeriesIntervals(intervals []time.Duration) CycleIntervals
- type CycleManager
- type CycleTicker
- func CompactionCycleTicker() CycleTicker
- func GeoCommitLoggerCycleTicker() CycleTicker
- func HnswCommitLoggerCycleTicker() CycleTicker
- func MemtableFlushCycleTicker() CycleTicker
- func NewExpTicker(minInterval, maxInterval time.Duration, base, steps uint) CycleTicker
- func NewFixedTicker(interval time.Duration) CycleTicker
- func NewLinearTicker(minInterval, maxInterval time.Duration, steps uint) CycleTicker
- func NewNoopTicker() CycleTicker
- func NewSeriesTicker(intervals []time.Duration) CycleTicker
- type RegisterOption
- type ShouldAbortCallback
Constants ¶
This section is empty.
Variables ¶
var ErrorCallbackNotFound = errors.New("callback not found")
Functions ¶
This section is empty.
Types ¶
type CycleCallback ¶ added in v1.21.0
type CycleCallback func(shouldAbort ShouldAbortCallback) bool
return value indicates whether actual work was done in the cycle
type CycleCallbackCtrl ¶ added in v1.21.0
type CycleCallbackCtrl interface { IsActive() bool Activate() error Deactivate(ctx context.Context) error Unregister(ctx context.Context) error }
Used to control of registered in CycleCallbacks container callback Allows deactivating and activating registered callback or unregistering it
func NewCallbackCtrlNoop ¶ added in v1.21.0
func NewCallbackCtrlNoop() CycleCallbackCtrl
func NewCombinedCallbackCtrl ¶ added in v1.21.0
func NewCombinedCallbackCtrl(routinesLimit int, ctrls ...CycleCallbackCtrl) CycleCallbackCtrl
Creates combined controller to manage all provided controllers at once as it was single instance. Methods (activate, deactivate, unregister) calls nested controllers' methods in parallel by number of goroutines given as argument. If < 1 value given, NumCPU is used.
type CycleCallbackGroup ¶ added in v1.21.0
type CycleCallbackGroup interface { // Adds CycleCallback method to container Register(id string, cycleCallback CycleCallback, options ...RegisterOption) CycleCallbackCtrl // Method of CycleCallback acting as single callback for all callbacks added to the container CycleCallback(shouldAbort ShouldAbortCallback) bool }
Container for multiple callbacks exposing CycleCallback method acting as single callback. Can be provided to CycleManager.
func NewCallbackGroup ¶ added in v1.21.0
func NewCallbackGroup(id string, logger logrus.FieldLogger, routinesLimit int) CycleCallbackGroup
func NewCallbackGroupNoop ¶ added in v1.21.0
func NewCallbackGroupNoop() CycleCallbackGroup
type CycleIntervals ¶ added in v1.21.0
func CompactionCycleIntervals ¶ added in v1.21.0
func CompactionCycleIntervals() CycleIntervals
3s . 6.8s .. 14.4s .... 29.6s ........ 60s
func GeoCommitLoggerCycleIntervals ¶ added in v1.21.0
func GeoCommitLoggerCycleIntervals() CycleIntervals
10s . 13.3s .. 20s .... 33.3s ........ 60s
func HnswCommitLoggerCycleIntervals ¶ added in v1.21.0
func HnswCommitLoggerCycleIntervals() CycleIntervals
500ms . 806ms .. 1.42s .... 2.65s ........ 5.1s ................10s
func MemtableFlushCycleIntervals ¶ added in v1.21.0
func MemtableFlushCycleIntervals() CycleIntervals
100ms . 258ms .. 574ms .... 1.206s ........ 2.471s ................ 5s
func NewExpIntervals ¶ added in v1.21.0
func NewExpIntervals(minInterval, maxInterval time.Duration, base, steps uint) CycleIntervals
func NewFixedIntervals ¶ added in v1.21.0
func NewFixedIntervals(interval time.Duration) CycleIntervals
func NewLinearIntervals ¶ added in v1.21.0
func NewLinearIntervals(minInterval, maxInterval time.Duration, steps uint) CycleIntervals
func NewSeriesIntervals ¶ added in v1.21.0
func NewSeriesIntervals(intervals []time.Duration) CycleIntervals
type CycleManager ¶
type CycleManager interface { Start() Stop(ctx context.Context) chan bool StopAndWait(ctx context.Context) error Running() bool }
func NewManager ¶ added in v1.21.0
func NewManager(cycleTicker CycleTicker, cycleCallback CycleCallback) CycleManager
func NewManagerNoop ¶ added in v1.21.0
func NewManagerNoop() CycleManager
type CycleTicker ¶ added in v1.18.3
type CycleTicker interface { Start() Stop() C() <-chan time.Time // called with bool value whenever cycle function finished execution // true - indicates cycle function actually did some processing // false - cycle function returned without doing anything CycleExecuted(executed bool) }
func CompactionCycleTicker ¶ added in v1.18.3
func CompactionCycleTicker() CycleTicker
run cycle ticker with fixed minimal interval and let each shard take care of its intervals
func GeoCommitLoggerCycleTicker ¶ added in v1.18.3
func GeoCommitLoggerCycleTicker() CycleTicker
run cycle ticker with fixed minimal interval and let each shard take care of its intervals
func HnswCommitLoggerCycleTicker ¶ added in v1.18.3
func HnswCommitLoggerCycleTicker() CycleTicker
run cycle ticker with fixed minimal interval and let each shard take care of its intervals
func MemtableFlushCycleTicker ¶ added in v1.18.3
func MemtableFlushCycleTicker() CycleTicker
run cycle ticker with fixed minimal interval and let each shard take care of its intervals
func NewExpTicker ¶ added in v1.18.3
func NewExpTicker(minInterval, maxInterval time.Duration, base, steps uint) CycleTicker
Creates ticker with intervals between minInterval and maxInterval values. Number of intervals in-between is determined by steps value. Ticker starts with minInterval value and with every report of executed "false" changes interval value to next one, up until maxInterval. Report of executed "true" resets interval to minInterval Example: for minInterval = 100ms, maxInterval = 5s, base = 2, steps = 4, intervals are 100ms . 427ms .. 1080ms .... 2387ms ........ 5000ms
If min- or maxInterval is <= 0 or base = 0 or steps = 0 or min > maxInterval, ticker will not fire
func NewFixedTicker ¶ added in v1.21.0
func NewFixedTicker(interval time.Duration) CycleTicker
Creates ticker with fixed interval. Interval is not changed regardless of execution results reported by cycle function
If interval <= 0 given, ticker will not fire
func NewLinearTicker ¶ added in v1.18.3
func NewLinearTicker(minInterval, maxInterval time.Duration, steps uint) CycleTicker
Creates ticker with intervals between minInterval and maxInterval values. Number of intervals in-between is determined by steps value. Ticker starts with minInterval value and with every report of executed "false" changes interval value to next one, up until maxInterval. Report of executed "true" resets interval to minInterval Example: for minInterval = 100ms, maxInterval = 5s, steps = 4, intervals are 100ms . 1325ms . 2550ms . 3775ms . 5000ms
If min- or maxInterval is <= 0 or steps = 0 or min > maxInterval, ticker will not fire
func NewNoopTicker ¶ added in v1.18.3
func NewNoopTicker() CycleTicker
func NewSeriesTicker ¶ added in v1.18.3
func NewSeriesTicker(intervals []time.Duration) CycleTicker
Creates ticker with set of interval values. Ticker starts with intervals[0] value and with every report of executed "false" changes interval value to next one in given array up until last one. Report of executed "true" resets interval to interval[0]
If any of intervals given is <= 0 given, ticker will not fire
type RegisterOption ¶ added in v1.21.0
type RegisterOption func(meta *cycleCallbackMeta)
func AsInactive ¶ added in v1.21.0
func AsInactive() RegisterOption
func WithIntervals ¶ added in v1.21.0
func WithIntervals(intervals CycleIntervals) RegisterOption
type ShouldAbortCallback ¶ added in v1.21.0
type ShouldAbortCallback func() bool
indicates whether cyclemanager's stop was requested to allow safely abort execution of CycleCallback and stop cyclemanager earlier