Documentation
¶
Overview ¶
Package ratelimit caps the requests the relay makes through one connection. The cap is one counter per connection, shared by everything that uses it (the listings and reads of the polling source): a request over the cap is not made, it fails with ErrRateLimited and the caller retries at its next poll.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRateLimited = errors.New("request rate limit reached")
ErrRateLimited is the cause of a request that was not made because the limit of its connection was reached.
Functions ¶
func Wrap ¶
func Wrap(connection string, perSecond int, store objectstore.ObjectStore, lister objectstore.Lister, now func() time.Time, ) (*Store, *Lister)
Wrap puts the store, and the lister when there is one, behind a limit of perSecond requests per second on the connection. The lister it returns is nil when lister is nil.
Types ¶
type Lister ¶
type Lister struct {
// contains filtered or unexported fields
}
Lister is a lister that shares the limit of a Store.
func (*Lister) CanHead ¶
CanHead implements objectstore.Lister: whether the lister behind the limit can describe one key. It makes no request.
func (*Lister) Head ¶
Head implements objectstore.Lister. A store that cannot answer is asked nothing and costs no request of the limit.
func (*Lister) List ¶
func (l *Lister) List(ctx context.Context, req objectstore.ListRequest) (objectstore.ListPage, error)
List implements objectstore.Lister.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an object store whose requests, and the ones of its lister, go through one limit.
func (*Store) CloseIdleConnections ¶
func (s *Store) CloseIdleConnections()
CloseIdleConnections passes the call on to the store behind the limit.
func (*Store) Connection ¶
Connection is the name of the connection the limit belongs to.
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, req objectstore.GetRequest) (objectstore.Object, error)
Get implements objectstore.ObjectStore.