package
0.0.0-20240205151722-28f9c355b091
Repository: https://github.com/ahwhy/mygolang.git
Documentation: pkg.go.dev

# Functions

NewBucket returns a new token bucket that fills at the rate of one token every fillInterval, up to the given maximum capacity.
NewBucketWithClock is identical to NewBucket but injects a testable clock interface.
NewBucketWithQuantum is similar to NewBucket, but allows the specification of the quantum size - quantum tokens are added every fillInterval.
NewBucketWithQuantumAndClock is like NewBucketWithQuantum, but also has a clock argument that allows clients to fake the passing of time.
NewBucketWithRate returns a token bucket that fills the bucket at the rate of rate tokens per second up to the given maximum capacity.
NewBucketWithRateAndClock is identical to NewBucketWithRate but injects a testable clock interface.
Reader returns a reader that is rate limited by the given token bucket.
Writer returns a reader that is rate limited by the given token bucket.

# Structs

Bucket represents a token bucket that fills at a predetermined rate.

# Interfaces

Clock represents the passage of time in a way that can be faked out for tests.