Documentation ¶
Index ¶
- func DefaultCircuitBreaker(name string) *gobreaker.CircuitBreaker
- func DefaultFailedExecutionStatus() []int
- func DefaultObserveOption(name string, r *http.Request, w *http.Response) prometheus.Labels
- func NewInstrumentation(histogram *prometheus.HistogramVec, name string, c *http.Client, ...) *http.Client
- func NewRetryable(conf RetryableConfig, c *http.Client) *http.Client
- func NewWithDefaultInstrumentation(name string, c *http.Client) *http.Client
- func RegexedObserveOption(regs map[string]string) func(name string, r *http.Request, w *http.Response) prometheus.Labels
- type CircuitBreaker
- type Doer
- type ObserveOption
- type RetryableConfig
- type RoundTripperFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCircuitBreaker ¶
func DefaultCircuitBreaker(name string) *gobreaker.CircuitBreaker
DefaultCircuitBreaker .
func DefaultFailedExecutionStatus ¶
func DefaultFailedExecutionStatus() []int
DefaultFailedExecutionStatus .
func DefaultObserveOption ¶ added in v1.0.4
DefaultObserveOption .
func NewInstrumentation ¶
func NewInstrumentation(histogram *prometheus.HistogramVec, name string, c *http.Client, opts ...ObserveOption) *http.Client
NewInstrumentation .
func NewRetryable ¶
func NewRetryable(conf RetryableConfig, c *http.Client) *http.Client
NewRetryable this is wrapper for `go-retryablehttp`. which has base from `net/http.Client` itself Make it as `net/http.Client` again
func NewWithDefaultInstrumentation ¶
NewWithDefaultInstrumentation .
func RegexedObserveOption ¶ added in v1.0.4
func RegexedObserveOption(regs map[string]string) func(name string, r *http.Request, w *http.Response) prometheus.Labels
RegexedObserveOption option add regex format for changing unique url path into general one, with keep other path that not provided on regex such as extra path on URL like`secure.payfazz.com/service-name`. Usually service-name will be generated when creating domain. Make sure to sort regex descending (longest to shortest)
`ex:` /service-name/user/123 to /service-name/user/{userId} `ex: /user/123 to /user/{userId}`
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker .
func NewCircuitBreaker ¶
func NewCircuitBreaker(name string, c *http.Client) *CircuitBreaker
NewCircuitBreaker .
func (*CircuitBreaker) SetFailedExecutionStatus ¶
func (c *CircuitBreaker) SetFailedExecutionStatus(status ...int) *CircuitBreaker
SetFailedExecutionStatus overriding failed execution status
func (*CircuitBreaker) StandardClient ¶
func (c *CircuitBreaker) StandardClient() *http.Client
StandardClient .
func (*CircuitBreaker) UseCircuitBreaker ¶
func (c *CircuitBreaker) UseCircuitBreaker(cb *gobreaker.CircuitBreaker) *CircuitBreaker
UseCircuitBreaker overriding ciruitbreaker system
type Doer ¶
Doer an interface to wrap net/http Client at first. Of course, net/http Client is usable without wrapper if you want to use it at the first. The purpose of this interface is make your implementation to third party using http method not mixed up with business things. Such as logging http request and response, request duration, retryable request, instrumentation, etc.
Even better with this interface, you can make more wrapper for whatever your needs. Sample wrapper is `LoggedDoer` which logging the request.
type ObserveOption ¶ added in v1.0.4
ObserveOption .
type RetryableConfig ¶
RetryableConfig .
func DefaultRetryableConfig ¶
func DefaultRetryableConfig() RetryableConfig
DefaultRetryableConfig .
type RoundTripperFunc ¶
The RoundTripperFunc type is an adapter to allow the use of ordinary functions as RoundTrippers. If f is a function with the appropriate signature, RountTripperFunc(f) is a RoundTripper that calls f.