pacer

package
v0.0.0-...-e391311 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

pacer is a utility package to make pacing and retrying API calls easy

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Paced

type Paced func() (bool, error)

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 New

func New() *Pacer

New returns a Pacer with sensible defaults

func (*Pacer) Call

func (p *Pacer) Call(fn Paced) (err error)

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

func (p *Pacer) CallNoRetry(fn Paced) error

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

func (p *Pacer) SetDecayConstant(decay uint) *Pacer

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

func (p *Pacer) SetMaxConnections(n int) *Pacer

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

func (p *Pacer) SetMaxSleep(t time.Duration) *Pacer

SetMaxSleep sets the maximum sleep time for the pacer

func (*Pacer) SetMinSleep

func (p *Pacer) SetMinSleep(t time.Duration) *Pacer

SetMinSleep sets the minimum sleep time for the pacer

func (*Pacer) SetRetries

func (p *Pacer) SetRetries(retries int) *Pacer

SetRetries sets the max number of tries for Call

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL