2017-10-08 11:28:03 -07:00
|
|
|
package limiter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2017-12-29 12:43:49 +01:00
|
|
|
"net/http"
|
2017-10-08 11:28:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Limiter defines an interface that implementors can use to rate limit I/O
|
|
|
|
// according to some policy defined and configured by the implementor.
|
|
|
|
type Limiter interface {
|
|
|
|
// Upstream returns a rate limited reader that is intended to be used in
|
|
|
|
// uploads.
|
|
|
|
Upstream(r io.Reader) io.Reader
|
|
|
|
|
2018-05-22 20:48:17 +02:00
|
|
|
// UpstreamWriter returns a rate limited writer that is intended to be used
|
|
|
|
// in uploads.
|
|
|
|
UpstreamWriter(w io.Writer) io.Writer
|
|
|
|
|
2017-10-08 11:28:03 -07:00
|
|
|
// Downstream returns a rate limited reader that is intended to be used
|
|
|
|
// for downloads.
|
|
|
|
Downstream(r io.Reader) io.Reader
|
2017-12-29 12:43:49 +01:00
|
|
|
|
2021-01-01 12:46:20 +01:00
|
|
|
// Downstream returns a rate limited reader that is intended to be used
|
|
|
|
// for downloads.
|
|
|
|
DownstreamWriter(r io.Writer) io.Writer
|
|
|
|
|
2017-12-29 12:43:49 +01:00
|
|
|
// Transport returns an http.RoundTripper limited with the limiter.
|
|
|
|
Transport(http.RoundTripper) http.RoundTripper
|
2017-10-08 11:28:03 -07:00
|
|
|
}
|