util

package
v0.0.0-...-f8e543c Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleThrottler

type SimpleThrottler struct {
	// ExecLimit represents the execution count limit after which the
	// throttler will indicates it's time to throttle
	ExecLimit uint32
	// PauseDuration represents how long the SimpleThrottler consider
	// we have to throttle execution.
	PauseDuration time.Duration
	// ThrottlingMessage is the warning message logged when the throttling is triggered.
	// An empty message won't log anything.
	ThrottlingMessage string
	// contains filtered or unexported fields
}

SimpleThrottler is a very basic throttler counting how many times something has been executed and indicating that this execution should be throttled if it has been executed more time ExecLimit. The pause duration is configurable with PauseDuration. After the pause, the throttler resets and restarts with the exact same behavior. There is no automatic decrease whatsoever in the execution count in time. SimpleThrottler is not thread-safe.

func NewSimpleThrottler

func NewSimpleThrottler(execLimit uint32, pauseDuration time.Duration, throttlingMessage string) SimpleThrottler

NewSimpleThrottler creates and returns a SimpleThrottler.

func (*SimpleThrottler) ShouldThrottle

func (t *SimpleThrottler) ShouldThrottle() bool

ShouldThrottle returns a boolean indicating if the throttle consider the execution should be throttled. Not thread-safe.

Jump to

Keyboard shortcuts

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