Documentation
¶
Index ¶
- Constants
- Variables
- type CircuitBreaker
- func (cb *CircuitBreaker) DeleteWithHeaders(ctx context.Context, path string, body []byte, headers map[string]string) (*http.Response, error)
- func (cb *CircuitBreaker) GetWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, ...) (*http.Response, error)
- func (cb *CircuitBreaker) PatchWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, ...) (*http.Response, error)
- func (cb *CircuitBreaker) PostWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, ...) (*http.Response, error)
- func (cb *CircuitBreaker) PutWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, ...) (*http.Response, error)
- type CircuitBreakerConfig
- type ErrorLog
- type HTTP
- type Health
- type HealthConfig
- type Log
- type Logger
- type Metrics
- type Options
- type Response
Constants ¶
const ( ClosedState = iota OpenState )
CircuitBreaker states.
Variables ¶
var ( // ErrCircuitOpen indicates that the circuit breaker is open. ErrCircuitOpen = errors.New("unable to connect to server at host") ErrUnexpectedCircuitBreakerResultType = errors.New("unexpected result type from circuit breaker") )
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶ added in v0.2.0
type CircuitBreaker struct { HTTP // contains filtered or unexported fields }
CircuitBreaker represents a circuit breaker implementation.
func NewCircuitBreaker ¶ added in v0.2.0
func NewCircuitBreaker(config CircuitBreakerConfig, h HTTP) *CircuitBreaker
NewCircuitBreaker creates a new CircuitBreaker instance based on the provided config.
func (*CircuitBreaker) DeleteWithHeaders ¶ added in v0.2.0
func (cb *CircuitBreaker) DeleteWithHeaders(ctx context.Context, path string, body []byte, headers map[string]string) ( *http.Response, error)
DeleteWithHeaders is a wrapper for doRequest with the DELETE method and headers.
func (*CircuitBreaker) GetWithHeaders ¶ added in v0.2.0
func (*CircuitBreaker) PatchWithHeaders ¶ added in v0.2.0
func (cb *CircuitBreaker) PatchWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, body []byte, headers map[string]string) (*http.Response, error)
PatchWithHeaders is a wrapper for doRequest with the PATCH method and headers.
func (*CircuitBreaker) PostWithHeaders ¶ added in v0.2.0
func (cb *CircuitBreaker) PostWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, body []byte, headers map[string]string) (*http.Response, error)
PostWithHeaders is a wrapper for doRequest with the POST method and headers.
func (*CircuitBreaker) PutWithHeaders ¶ added in v0.2.0
func (cb *CircuitBreaker) PutWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, body []byte, headers map[string]string) (*http.Response, error)
PutWithHeaders is a wrapper for doRequest with the PUT method and headers.
type CircuitBreakerConfig ¶ added in v0.2.0
type CircuitBreakerConfig struct { Threshold int // Threshold represents the max no of retry before switching the circuit breaker state. Interval time.Duration // Interval represents the time interval duration between hitting the HealthURL }
CircuitBreakerConfig holds the configuration for the CircuitBreaker.
type HTTP ¶
type HTTP interface { // HealthCheck to get the service health and report it to the current application HealthCheck(ctx context.Context) *Health // contains filtered or unexported methods }
func NewHTTPService ¶
NewHTTPService function creates a new instance of the httpService struct, which implements the HTTP interface. It initializes the http.Client, url, Tracer, and Logger fields of the httpService struct with the provided values.
type HealthConfig ¶ added in v0.2.0
type HealthConfig struct {
HealthEndpoint string
}
type Metrics ¶ added in v0.3.0
type Metrics interface { IncrementCounter(ctx context.Context, name string, labels ...string) DeltaUpDownCounter(ctx context.Context, name string, value float64, labels ...string) RecordHistogram(ctx context.Context, name string, value float64, labels ...string) SetGauge(name string, value float64) }