Documentation
¶
Index ¶
- type CycleFunc
- 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 NewFixedIntervalTicker(interval time.Duration) CycleTicker
- func NewLinearTicker(minInterval, maxInterval time.Duration, steps uint) CycleTicker
- func NewNoopTicker() CycleTicker
- func NewSeriesTicker(intervals []time.Duration) CycleTicker
- type FixedIntervalTicker
- type NoopTicker
- type SeriesTicker
- type ShouldBreakFunc
- type TickerProvider
- func ExpTickerProvider(minInterval, maxInterval time.Duration, base, steps uint) TickerProvider
- func FixedIntervalTickerProvider(interval time.Duration) TickerProvider
- func LinearTickerProvider(minInterval, maxInterval time.Duration, steps uint) TickerProvider
- func SeriesTickerProvider(intervals []time.Duration) TickerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CycleFunc ¶
type CycleFunc func(shouldBreak ShouldBreakFunc) bool
return value indicates whether actual work was done in the cycle
type CycleManager ¶
func New ¶
func New(cycleTicker CycleTicker, cycleFunc CycleFunc) *CycleManager
func (*CycleManager) Running ¶
func (c *CycleManager) Running() bool
func (*CycleManager) Start ¶
func (c *CycleManager) Start()
Starts instance, does not block Does nothing if instance is already started
func (*CycleManager) Stop ¶
func (c *CycleManager) Stop(ctx context.Context) (stopResult chan bool)
Stops running instance, does not block Returns channel with final stop result - true / false
If given context is cancelled before it is handled by stop logic, instance is not stopped If called multiple times, all contexts have to be cancelled to cancel stop (any valid will result in stopping instance) stopResult is the same (consistent) for multiple calls
func (*CycleManager) StopAndWait ¶
func (c *CycleManager) StopAndWait(ctx context.Context) error
Stops running instance, waits for stop to occur or context to expire (which comes first) Returns error if instance was not stopped
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
3s . 6.8s .. 14.4s .... 29.6s ........ 60s
func GeoCommitLoggerCycleTicker ¶ added in v1.18.3
func GeoCommitLoggerCycleTicker() CycleTicker
10s . 13.3s .. 20s .... 33.3s ........ 60s
func HnswCommitLoggerCycleTicker ¶ added in v1.18.3
func HnswCommitLoggerCycleTicker() CycleTicker
500ms . 806ms .. 1.42s .... 2.65s ........ 5.1s ................10s
func MemtableFlushCycleTicker ¶ added in v1.18.3
func MemtableFlushCycleTicker() CycleTicker
100ms . 258ms .. 574ms .... 1.206s ........ 2.471s ................ 5s
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 NewFixedIntervalTicker ¶ added in v1.18.3
func NewFixedIntervalTicker(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 FixedIntervalTicker ¶ added in v1.18.3
type FixedIntervalTicker struct {
// contains filtered or unexported fields
}
func (*FixedIntervalTicker) C ¶ added in v1.18.3
func (t *FixedIntervalTicker) C() <-chan time.Time
func (*FixedIntervalTicker) CycleExecuted ¶ added in v1.18.3
func (t *FixedIntervalTicker) CycleExecuted(executed bool)
func (*FixedIntervalTicker) Start ¶ added in v1.18.3
func (t *FixedIntervalTicker) Start()
func (*FixedIntervalTicker) Stop ¶ added in v1.18.3
func (t *FixedIntervalTicker) Stop()
type NoopTicker ¶ added in v1.18.3
type NoopTicker struct {
// contains filtered or unexported fields
}
func (*NoopTicker) C ¶ added in v1.18.3
func (t *NoopTicker) C() <-chan time.Time
func (*NoopTicker) CycleExecuted ¶ added in v1.18.3
func (t *NoopTicker) CycleExecuted(executed bool)
func (*NoopTicker) Start ¶ added in v1.18.3
func (t *NoopTicker) Start()
func (*NoopTicker) Stop ¶ added in v1.18.3
func (t *NoopTicker) Stop()
type SeriesTicker ¶ added in v1.18.3
type SeriesTicker struct {
// contains filtered or unexported fields
}
func (*SeriesTicker) C ¶ added in v1.18.3
func (t *SeriesTicker) C() <-chan time.Time
func (*SeriesTicker) CycleExecuted ¶ added in v1.18.3
func (t *SeriesTicker) CycleExecuted(executed bool)
func (*SeriesTicker) Start ¶ added in v1.18.3
func (t *SeriesTicker) Start()
func (*SeriesTicker) Stop ¶ added in v1.18.3
func (t *SeriesTicker) Stop()
type ShouldBreakFunc ¶ added in v1.18.3
type ShouldBreakFunc func() bool
indicates whether cyclemanager's stop was requested to allow safely break execution of CycleFunc and stop cyclemanager earlier
type TickerProvider ¶ added in v1.18.3
type TickerProvider func() CycleTicker
func ExpTickerProvider ¶ added in v1.18.3
func ExpTickerProvider(minInterval, maxInterval time.Duration, base, steps uint) TickerProvider
func FixedIntervalTickerProvider ¶ added in v1.18.3
func FixedIntervalTickerProvider(interval time.Duration) TickerProvider
func LinearTickerProvider ¶ added in v1.18.3
func LinearTickerProvider(minInterval, maxInterval time.Duration, steps uint) TickerProvider
func SeriesTickerProvider ¶ added in v1.18.3
func SeriesTickerProvider(intervals []time.Duration) TickerProvider