circuitbreaker

package module
v0.0.0-...-5dbc9c9 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

Circuit breaker for Caddy

This module implements a simple but effective circuit breaker for Caddy's reverse proxy.

Module name: http.reverse_proxy.circuit_breakers.simple

Works well, but help would be appreciated to expand its documentation!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The threshold over sliding window that would trip the circuit breaker
	Threshold float64 `json:"threshold,omitempty"`
	// Possible values: latency, error_ratio, and status_ratio. It
	// defaults to latency.
	Factor string `json:"factor,omitempty"`
	// How long to wait after the circuit is tripped before allowing operations to resume.
	// The default is 5s.
	TripDuration caddy.Duration `json:"trip_duration,omitempty"`
}

Config represents the configuration of a circuit breaker.

type Simple

type Simple struct {
	Config
	// contains filtered or unexported fields
}

Simple implements circuit breaking functionality for requests within this process over a sliding time window.

func (Simple) CaddyModule

func (Simple) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Simple) OK

func (c *Simple) OK() bool

OK returns whether the circuit breaker is tripped or not.

func (*Simple) Provision

func (c *Simple) Provision(ctx caddy.Context) error

Provision sets up a configured circuit breaker.

func (*Simple) RecordMetric

func (c *Simple) RecordMetric(statusCode int, latency time.Duration)

RecordMetric records a response status code and execution time of a request. This function should be run in a separate goroutine.

Jump to

Keyboard shortcuts

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