retry

package
v2.0.0-...-0175b30 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Closure = func() func(chan int) {
	retryIn := 0
	fibonacci := Fibonacci()
	return func(stopChan chan int) {
		if retryIn > 0 {
			durationString := fmt.Sprintf("%vs", retryIn)
			duration, _ := time.ParseDuration(durationString)
			defer log.Sync()
			log.Warn("Retrying", zap.Int("seconds", retryIn))

			select {
			case <-stopChan:
				break
			case <-time.After(duration):
				break
			}
		}
		retryIn = fibonacci()
	}
}

Closure - a useful closure we can use when there is a problem connecting to the broker. It uses Fibonacci sequence to space out retry attempts

Functions

func Fibonacci

func Fibonacci() func() int

Fibonacci returns successive Fibonacci numbers starting from 1

func FibonacciNext

func FibonacciNext(start int) int

FibonacciNext returns next number in Fibonacci sequence greater than start

Types

This section is empty.

Jump to

Keyboard shortcuts

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