Documentation
¶
Overview ¶
Package throttle allows for throttling iterators.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IterationsPerInterval ¶
type IterationsPerInterval struct { // Maximum is the maximum amount of iterations allowed within the timespan defined by Interval. // Must be > 0. Maximum int // Timeframe defines the timespan during which at most Maximum iterations may be invoked. // Must be > 0. Timeframe time.Duration }
IterationsPerInterval is a blueprint for creating throttling strategies that pass at most a certain number of items within a given timeframe from a sequence.
func (IterationsPerInterval) Strategy ¶
func (strategyBlueprint IterationsPerInterval) Strategy() (Strategy, error)
Strategy creates a strategy with the configuration from the blueprint. The Strategy is independent from the blueprint afterwards.
type Strategy ¶
type Strategy interface { // Waiter creates a Waiter. A Waiter should be independent from other Waiters created from the same Strategy. Waiter() Waiter }
Strategy describes how throttling is done.
type Waiter ¶
type Waiter interface {
// Wait waits until the next iteration may be invoked. It is called before every yield.
Wait()
}
Click to show internal directories.
Click to hide internal directories.