utils

package
v0.0.0-...-23bbeeb Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2016 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RetryClosure = func() func() {
	retryIn := 0
	fibonacci := Fibonacci()
	return func() {
		if retryIn > 0 {
			durationString := fmt.Sprintf("%vs", retryIn)
			duration, _ := time.ParseDuration(durationString)

			log.Printf("Retrying in %v seconds", retryIn)
			time.Sleep(duration)
		}
		retryIn = fibonacci()
	}
}

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 ReflectValue

func ReflectValue(theType string, value interface{}) (reflect.Value, error)

ReflectValue converts interface{} to reflect.Value based on string type

Types

This section is empty.

Jump to

Keyboard shortcuts

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