Documentation ¶
Overview ¶
Package throttling implements wrapper around blob.Storage that adds throttling to all calls. Throttling is performed for both operations and byte counts (upload and download separately).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Limits ¶
type Limits struct { ReadsPerSecond float64 `json:"readsPerSecond,omitempty"` WritesPerSecond float64 `json:"writesPerSecond,omitempty"` ListsPerSecond float64 `json:"listsPerSecond,omitempty"` UploadBytesPerSecond float64 `json:"maxUploadSpeedBytesPerSecond,omitempty"` DownloadBytesPerSecond float64 `json:"maxDownloadSpeedBytesPerSecond,omitempty"` ConcurrentReads int `json:"concurrentReads,omitempty"` ConcurrentWrites int `json:"concurrentWrites,omitempty"` }
Limits encapsulates all limits for a Throttler.
type SettableThrottler ¶
type SettableThrottler interface { Throttler Limits() Limits SetLimits(limits Limits) error OnUpdate(handler UpdatedHandler) }
SettableThrottler exposes methods to set throttling limits.
func NewThrottler ¶
func NewThrottler(limits Limits, window time.Duration, initialFillRatio float64) (SettableThrottler, error)
NewThrottler returns a Throttler with provided limits.
type Throttler ¶
type Throttler interface { BeforeOperation(ctx context.Context, op string) AfterOperation(ctx context.Context, op string) // BeforeDownload acquires the specified number of downloaded bytes // possibly blocking until enough are available. BeforeDownload(ctx context.Context, numBytes int64) // BeforeUpload acquires the specified number of upload bytes // possibly blocking until enough are available. BeforeUpload(ctx context.Context, numBytes int64) // ReturnUnusedDownloadBytes returns the specified number of unused download bytes. ReturnUnusedDownloadBytes(ctx context.Context, numBytes int64) }
Throttler implements throttling policy by blocking before certain operations are attempted to ensure we don't exceed the desired rate of operations/bytes uploaded/downloaded.
type UpdatedHandler ¶ added in v0.11.0
UpdatedHandler is invoked as part of SetLimits() after limits are updated.
Click to show internal directories.
Click to hide internal directories.