lazysync

package
v2.18.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LazySyncRateLimiter

type LazySyncRateLimiter struct {
	// contains filtered or unexported fields
}

LazySyncRateLimiter is a limiter that syncs its state lazily with another limiter.

func NewLazySyncRateLimiter

func NewLazySyncRateLimiter(limiter ratelimiter.RateLimiter,
	interval time.Duration,
	numSync uint32,
	jobGroup *jobs.JobGroup,
) (*LazySyncRateLimiter, error)

NewLazySyncRateLimiter creates a new LazySyncLimiter.

func (*LazySyncRateLimiter) Close

func (lsl *LazySyncRateLimiter) Close() error

Close closes the limiter.

func (*LazySyncRateLimiter) GetPassThrough

func (lsl *LazySyncRateLimiter) GetPassThrough() bool

GetPassThrough returns whether the limiter should pass through requests when it is not initialized.

func (*LazySyncRateLimiter) Name

func (lsl *LazySyncRateLimiter) Name() string

Name returns the name of the limiter.

func (*LazySyncRateLimiter) Return

func (lsl *LazySyncRateLimiter) Return(ctx context.Context, label string, n float64) (float64, float64)

Return returns n tokens to the limiter.

func (*LazySyncRateLimiter) SetPassThrough

func (lsl *LazySyncRateLimiter) SetPassThrough(passThrough bool)

SetPassThrough sets whether the limiter should pass through requests when it is not initialized.

func (*LazySyncRateLimiter) Take

Take takes n tokens from the limiter.

func (*LazySyncRateLimiter) TakeIfAvailable

func (lsl *LazySyncRateLimiter) TakeIfAvailable(ctx context.Context, label string, n float64) (bool, time.Duration, float64, float64)

TakeIfAvailable takes n tokens from the limiter if they are available.

Jump to

Keyboard shortcuts

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