Documentation
¶
Index ¶
- Constants
- Variables
- type CircuitBreaker
- func (cb *CircuitBreaker) Delete(ctx context.Context, path string, body []byte) (*http.Response, error)
- func (cb *CircuitBreaker) DeleteWithHeaders(ctx context.Context, path string, body []byte, headers map[string]string) (*http.Response, error)
- func (cb *CircuitBreaker) Get(ctx context.Context, api string, queryParams map[string]interface{}) (*http.Response, error)
- func (cb *CircuitBreaker) GetWithHeaders(ctx context.Context, path string, queryParams map[string]interface{}, ...) (*http.Response, error)
- func (cb *CircuitBreaker) Patch(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) Post(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 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) Delete ¶ added in v0.2.0
func (cb *CircuitBreaker) Delete(ctx context.Context, path string, body []byte) (*http.Response, error)
Delete is a wrapper for doRequest with the DELETE method.
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) Patch ¶ added in v0.2.0
func (cb *CircuitBreaker) Patch(ctx context.Context, path string, queryParams map[string]interface{}, body []byte) (*http.Response, error)
Patch is a wrapper for doRequest with the PATCH method.
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) Post ¶ added in v0.2.0
func (cb *CircuitBreaker) Post(ctx context.Context, path string, queryParams map[string]interface{}, body []byte) (*http.Response, error)
Post is a wrapper for doRequest with the POST method.
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
}