Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hedged ¶
type Hedged[T any] struct { // The function must be thread-safe because multiple instances may be running // concurrently. The function must return as soon as possible after context // cancellation, otherwise the speculation makes no sense. // // The function argument indicates whether this is a speculative retry attempt. Call Call[T] Trigger <-chan time.Time // FailFast specifies how a failure is handled. If it is set to true: // - the result received first is returned, regardless of anything. // - if Call fails before the trigger fires, it won't be retried. FailFast bool // Throttler executes call retries. Optional. Throttler }
Hedged executes Call with a speculative retry after trigger fires if it has not returned earlier.
By default, if one of the attempts fails, another one is not canceled. In this case the speculative attempt will not start until the trigger fires. For more granular control, use FailFast.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter limits the number of tasks executed. Once the limit is reached, no more runs will be done.
func NewLimiter ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements Throttler using golang.org/x/time/rate with the given rate (ops per second) and burst size.
func NewRateLimiter ¶
func NewRateLimiter(ratePerSec float64, burst int) *RateLimiter
func (*RateLimiter) Run ¶
func (r *RateLimiter) Run(f func())
Click to show internal directories.
Click to hide internal directories.