Documentation ¶
Overview ¶
pacer is a utility package to make pacing and retrying API calls easy
Index ¶
- type Paced
- type Pacer
- func (p *Pacer) Call(fn Paced) (err error)
- func (p *Pacer) CallNoRetry(fn Paced) error
- func (p *Pacer) SetDecayConstant(decay uint) *Pacer
- func (p *Pacer) SetMaxConnections(n int) *Pacer
- func (p *Pacer) SetMaxSleep(t time.Duration) *Pacer
- func (p *Pacer) SetMinSleep(t time.Duration) *Pacer
- func (p *Pacer) SetRetries(retries int) *Pacer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Paced ¶
Paced is a function which is called by the Call and CallNoRetry methods. It should return a boolean, true if it would like to be retried, and an error. This error may be returned or returned wrapped in a RetryError.
type Pacer ¶
type Pacer struct {
// contains filtered or unexported fields
}
func (*Pacer) Call ¶
Call paces the remote operations to not exceed the limits and retry on rate limit exceeded
This calls fn, expecting it to return a retry flag and an error. This error may be returned wrapped in a RetryError if the number of retries is exceeded.
func (*Pacer) CallNoRetry ¶
Pace the remote operations to not exceed Amazon's limits and return a retry error on rate limit exceeded
This calls fn and wraps the output in a RetryError if it would like it to be retried
func (*Pacer) SetDecayConstant ¶
SetDecayConstant sets the decay constant for the pacer
This is the speed the time falls back to the minimum after errors have occurred.
bigger for slower decay, exponential
func (*Pacer) SetMaxConnections ¶
SetMaxConnections sets the maximum number of concurrent connections. Setting the value to 0 will allow unlimited number of connections. Should not be changed once you have started calling the pacer. By default this will be set to fs.Config.Checkers.
func (*Pacer) SetMaxSleep ¶
SetMaxSleep sets the maximum sleep time for the pacer
func (*Pacer) SetMinSleep ¶
SetMinSleep sets the minimum sleep time for the pacer
func (*Pacer) SetRetries ¶
SetRetries sets the max number of tries for Call