Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRLReadWriter ¶
func NewRLReadWriter(rw io.ReadWriter, rl *RateLimit, cancel <-chan struct{}) io.ReadWriter
NewRLReadWriter wraps a io.ReadWriter into a rlReadWriter.
Types ¶
type RateLimit ¶
type RateLimit struct {
// contains filtered or unexported fields
}
RateLimit declares the global rate limit for read and write operations on a io.ReadWriter. Whenever a caller wants to read or write, they have to wait until readBlock/writeBlock to start the actual read or write operation. Each caller also pushes these timestamps into the future to prevent other callers to read or write prematurely.
func NewRateLimit ¶
NewRateLimit creates a new rateLimit object that can be used to initialize rate-limited readers and writers.
Click to show internal directories.
Click to hide internal directories.