circuitbreaker

package
v0.0.0-...-7d43bac Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package circuitbreaker provides support for circuit breaker pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircuitBreaker

type CircuitBreaker interface {
	Execute(f func() (interface{}, error), opts ...Option) (interface{}, error)
}

CircuitBreaker represents Circuit Breaker pattern mechanism.

type DefaultCircuitBreaker

type DefaultCircuitBreaker struct{}

DefaultCircuitBreaker is default quark-go implementation of Circuit Breaker pattern.

func (DefaultCircuitBreaker) Execute

func (cb DefaultCircuitBreaker) Execute(f func() (interface{}, error), opts ...Option) (interface{}, error)

Execute implements Circuit Breaker pattern for function f. Default settings are: 3 attempts (1 failure + 3 retries), 5 second sleep time between retries.

type Option

type Option func(*Options)

Option represents function which is used to apply circuit breaker options.

func Retry

func Retry(retries int) Option

Retry allows to set number of retries.

func Timeout

func Timeout(timeout time.Duration) Option

Timeout allows to set sleep period between retries.

type Options

type Options struct {
	Attempts int           // number of retries
	Timeout  time.Duration // sleep period between each retry
}

Options represents circuit breaker options.

Jump to

Keyboard shortcuts

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