Documentation ¶
Index ¶
- Constants
- func DecorateConsumer[T any](limiter RateLimiter, fn func(T) error) func(T) error
- func DecorateFunction[T any, R any](limiter RateLimiter, fn func(T) (R, error)) func(T) (R, error)
- func DecorateRunnable(limiter RateLimiter, fn func() error) func() error
- func DecorateSupplier[T any](limiter RateLimiter, fn func() (T, error)) func() (T, error)
- type Config
- type ConfigBuilder
- type Event
- type EventListener
- type EventType
- type FailureEvent
- type Metrics
- type NotPermittedError
- type RateLimiter
- type SuccessEvent
Constants ¶
View Source
const DefaultLimitForPeriod int64 = 50
View Source
const DefaultLimitRefreshPeriod = time.Nanosecond * 500
View Source
const DefaultTimeoutDuration = time.Second * 5
Variables ¶
This section is empty.
Functions ¶
func DecorateConsumer ¶
func DecorateConsumer[T any](limiter RateLimiter, fn func(T) error) func(T) error
func DecorateFunction ¶
func DecorateFunction[T any, R any](limiter RateLimiter, fn func(T) (R, error)) func(T) (R, error)
func DecorateRunnable ¶
func DecorateRunnable(limiter RateLimiter, fn func() error) func() error
func DecorateSupplier ¶
func DecorateSupplier[T any](limiter RateLimiter, fn func() (T, error)) func() (T, error)
Types ¶
type ConfigBuilder ¶
type ConfigBuilder func(*Config)
func WithLimitForPeriod ¶
func WithLimitForPeriod(limitForPeriod int64) ConfigBuilder
func WithLimitRefreshPeriod ¶
func WithLimitRefreshPeriod(limitRefreshPeriod time.Duration) ConfigBuilder
func WithTimeoutDuration ¶
func WithTimeoutDuration(timeoutDuration time.Duration) ConfigBuilder
type EventListener ¶
type EventListener interface { OnSuccessFunc(func(SuccessEvent)) EventListener OnFailureFunc(func(FailureEvent)) EventListener DismissSuccessFunc(func(SuccessEvent)) EventListener DismissFailureFunc(func(FailureEvent)) EventListener OnSuccess(fn.Consumer[SuccessEvent]) EventListener OnFailure(fn.Consumer[FailureEvent]) EventListener DismissSuccess(fn.Consumer[SuccessEvent]) EventListener DismissFailure(fn.Consumer[FailureEvent]) EventListener }
type FailureEvent ¶ added in v0.4.1
type FailureEvent interface { Event }
type NotPermittedError ¶
type NotPermittedError struct {
// contains filtered or unexported fields
}
func (*NotPermittedError) Error ¶
func (e *NotPermittedError) Error() string
type RateLimiter ¶
type RateLimiter interface { Name() string Metrics() Metrics EventListener() EventListener AcquirePermission() error }
func NewRateLimiter ¶
func NewRateLimiter(name string, configs ...ConfigBuilder) RateLimiter
type SuccessEvent ¶ added in v0.4.1
type SuccessEvent interface { Event }
Click to show internal directories.
Click to hide internal directories.