Documentation ¶
Index ¶
- type CircuitBreaker
- func (cb *CircuitBreaker) CallCustomFuncWithRetries(ctx context.Context, fn func() error) error
- func (cb *CircuitBreaker) ConfigureHystrix(commands []string)
- func (cb *CircuitBreaker) Deregister()
- func (cb *CircuitBreaker) PerformCustomServiceRequest(ctx context.Context, breakerName string, fn func() error, ...) error
- func (cb *CircuitBreaker) PerformHTTPRequest(ctx context.Context, breakerName string, url string, method string, ...) ([]byte, error)
- func (cb *CircuitBreaker) PerformRequest(ctx context.Context, breakerName string, req *http.Request, ...) ([]byte, error)
- func (cb *CircuitBreaker) PerformServiceRequest(ctx context.Context, breakerName string, fn func() (interface{}, error), ...) (interface{}, error)
- type DiscoveryToken
- type FallbackFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct { // Logger holds a reference to the zap logger loging handle Logger *zap.Logger // Retries specifies the number of retries to perform within a circuit breaker Retries int // AMQPClient witholds a reference to the rabbitMQ client AMQPClient *rabbitmq.RabbitMQClient // HTTPClient is an http client through which http operations will be performed HTTPClient *http.Client }
A CircuitBreaker represents an active circuit breaker object that in which operations can be performed within.
func NewCircuitBreaker ¶
func NewCircuitBreaker(logger *zap.Logger, retries int, amqpClient *rabbitmq.RabbitMQClient, client *http.Client) *CircuitBreaker
NewCircuitBreaker returns a new reference to a circuit breaker
func (*CircuitBreaker) CallCustomFuncWithRetries ¶
func (cb *CircuitBreaker) CallCustomFuncWithRetries(ctx context.Context, fn func() error) error
CallCustomFuncWithRetries calls a given function in a retry loop
func (*CircuitBreaker) ConfigureHystrix ¶
func (cb *CircuitBreaker) ConfigureHystrix(commands []string)
ConfigureHystrix sets up hystrix circuit breakers.
func (*CircuitBreaker) Deregister ¶
func (cb *CircuitBreaker) Deregister()
Deregister publishes a Deregister token to Hystrix/Turbine
func (*CircuitBreaker) PerformCustomServiceRequest ¶
func (cb *CircuitBreaker) PerformCustomServiceRequest(ctx context.Context, breakerName string, fn func() error, fallback func(error) error) error
PerformCustomServiceClientRequestCircuitBreaker performs the supplied service level request within a circuit breaker.
func (*CircuitBreaker) PerformHTTPRequest ¶
func (cb *CircuitBreaker) PerformHTTPRequest(ctx context.Context, breakerName string, url string, method string, fallback func(error) error) ([]byte, error)
PerformHTTPRequest performs a HTTP call inside a circuit breaker.
func (*CircuitBreaker) PerformRequest ¶
func (cb *CircuitBreaker) PerformRequest( ctx context.Context, breakerName string, req *http.Request, fallback func(error) error) ([]byte, error)
PerformRequest performs the supplied http.Request within a circuit breaker.
func (*CircuitBreaker) PerformServiceRequest ¶
func (cb *CircuitBreaker) PerformServiceRequest(ctx context.Context, breakerName string, fn func() (interface{}, error), fallback func(error) error) (interface{}, error)
PerformServiceClientRequestCircuitBreaker performs the supplied service level request within a circuit breaker.
type DiscoveryToken ¶
type DiscoveryToken struct { State string `json:"state"` // UP, RUNNING, DOWN ?? Address string `json:"address"` }
DiscoveryToken defines a struct for transmitting the state of a hystrix stream producer.