Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // PluginID is used to check existence of the backoff plugin PluginID = (*Plugin)(nil) )
Functions ¶
This section is empty.
Types ¶
type Backoff ¶
type Backoff struct { // MaxAttempts specifies max attempts to try before erroring MaxAttempts int // BackoffInterval is duration to increment each attempt BackoffInterval float64 // Jitter specifies deviation from backoff interval Jitter float64 // MinInterval specifies minimum time allowed for backoff interval MinInterval time.Duration // MaxInterval specifies maximum time allowed for backoff interval MaxInterval time.Duration // contains filtered or unexported fields }
Backoff keeps track of connection retry attempts and calculates the delay between each one.
func DefaultBackoff ¶
func DefaultBackoff() *Backoff
DefaultBackoff creates a default configuration for Backoff.
func (*Backoff) ForAttempt ¶
ForAttempt calculates the appropriate exponential duration given an attempt count
func (*Backoff) NextDuration ¶
NextDuration returns the duration and increases the number of attempts
func (*Backoff) TimeoutExceeded ¶
TimeoutExceeded returns true if the backoff total duration has been exceeded
type Plugin ¶
Plugin is the backoff plugin
func New ¶
func New(opts ...PluginOption) *Plugin
New returns a new backoff plugin with specified options
func (*Plugin) PeerDisconnect ¶
func (p *Plugin) PeerDisconnect(client *network.PeerClient)
PeerDisconnect implements the plugin callback
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption are configurable options for the backoff plugin
func WithInitialDelay ¶
func WithInitialDelay(d time.Duration) PluginOption
WithInitialDelay specifies initial backoff interval
func WithMaxAttempts ¶
func WithMaxAttempts(i int) PluginOption
WithMaxAttempts specifies max attempts to retry upon client disconnect