Documentation
¶
Index ¶
- func NewResilientClient(cfg *ResilienceConfig) *http.Client
- func NewResilientTransport(baseTransport http.RoundTripper, cfg *ResilienceConfig) http.RoundTripper
- type AdaptiveThrottlerConfig
- type BulkheadConfig
- type CacheConfig
- type CircuitBreakerConfig
- type Client
- func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) DeleteJSON(ctx context.Context, path string, result any) error
- func (c *Client) Do(ctx context.Context, method, path string, body any) (*http.Response, error)
- func (c *Client) DoWithResponse(ctx context.Context, method, path string, body, result any) error
- func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) GetErrorParser() *ErrorParserChain
- func (c *Client) GetHTTPClient() *http.Client
- func (c *Client) GetJSON(ctx context.Context, path string, result any) error
- func (c *Client) Patch(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) PatchJSON(ctx context.Context, path string, body, result any) error
- func (c *Client) Post(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) PostJSON(ctx context.Context, path string, body, result any) error
- func (c *Client) Put(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) PutJSON(ctx context.Context, path string, body, result any) error
- func (c *Client) RemoveHeader(key string)
- func (c *Client) SetBaseURL(baseURL string)
- func (c *Client) SetErrorParser(parser *ErrorParserChain)
- func (c *Client) SetHTTPClient(httpClient *http.Client)
- func (c *Client) SetHeader(key, value string)
- func (c *Client) SetHeaders(headers map[string]string)
- type ClientOption
- func WithBaseURL(baseURL string) ClientOption
- func WithCustomJsonMarshaler(marshal JSONMarshal) ClientOption
- func WithCustomJsonUnmarshaler(unmarshal JSONUnmarshal) ClientOption
- func WithErrorParser(parser ErrorResponseParser) ClientOption
- func WithHTTPClient(httpClient *http.Client) ClientOption
- func WithHeader(key, value string) ClientOption
- func WithHeaders(headers map[string]string) ClientOption
- func WithResilienceConfig(cfg *ResilienceConfig) ClientOption
- func WithTimeout(timeout time.Duration) ClientOption
- type Error
- type ErrorParserChain
- type ErrorResponseParser
- type ErrorType
- type Executor
- type FallbackConfig
- type GenericErrorParser
- type HedgeConfig
- type JSONMarshal
- type JSONUnmarshal
- type MockErrorResponseParser
- type MockErrorResponseParser_CanParse_Call
- func (_c *MockErrorResponseParser_CanParse_Call) Return(b bool) *MockErrorResponseParser_CanParse_Call
- func (_c *MockErrorResponseParser_CanParse_Call) Run(run func(body []byte)) *MockErrorResponseParser_CanParse_Call
- func (_c *MockErrorResponseParser_CanParse_Call) RunAndReturn(run func(body []byte) bool) *MockErrorResponseParser_CanParse_Call
- type MockErrorResponseParser_Expecter
- type MockErrorResponseParser_Parse_Call
- func (_c *MockErrorResponseParser_Parse_Call) Return(parsedErrorResponse *ParsedErrorResponse, err error) *MockErrorResponseParser_Parse_Call
- func (_c *MockErrorResponseParser_Parse_Call) Run(run func(body []byte)) *MockErrorResponseParser_Parse_Call
- func (_c *MockErrorResponseParser_Parse_Call) RunAndReturn(run func(body []byte) (*ParsedErrorResponse, error)) *MockErrorResponseParser_Parse_Call
- type MockExecutor
- func (_mock *MockExecutor) Delete(ctx context.Context, path string) (*http.Response, error)
- func (_mock *MockExecutor) DeleteJSON(ctx context.Context, path string, result any) error
- func (_mock *MockExecutor) Do(ctx context.Context, method string, path string, body any) (*http.Response, error)
- func (_mock *MockExecutor) DoWithResponse(ctx context.Context, method string, path string, body any, result any) error
- func (_m *MockExecutor) EXPECT() *MockExecutor_Expecter
- func (_mock *MockExecutor) Get(ctx context.Context, path string) (*http.Response, error)
- func (_mock *MockExecutor) GetErrorParser() *ErrorParserChain
- func (_mock *MockExecutor) GetHTTPClient() *http.Client
- func (_mock *MockExecutor) GetJSON(ctx context.Context, path string, result any) error
- func (_mock *MockExecutor) Patch(ctx context.Context, path string, body any) (*http.Response, error)
- func (_mock *MockExecutor) PatchJSON(ctx context.Context, path string, body any, result any) error
- func (_mock *MockExecutor) Post(ctx context.Context, path string, body any) (*http.Response, error)
- func (_mock *MockExecutor) PostJSON(ctx context.Context, path string, body any, result any) error
- func (_mock *MockExecutor) Put(ctx context.Context, path string, body any) (*http.Response, error)
- func (_mock *MockExecutor) PutJSON(ctx context.Context, path string, body any, result any) error
- func (_mock *MockExecutor) RemoveHeader(key string)
- func (_mock *MockExecutor) SetBaseURL(baseURL string)
- func (_mock *MockExecutor) SetErrorParser(parser *ErrorParserChain)
- func (_mock *MockExecutor) SetHTTPClient(httpClient *http.Client)
- func (_mock *MockExecutor) SetHeader(key string, value string)
- func (_mock *MockExecutor) SetHeaders(headers map[string]string)
- type MockExecutor_DeleteJSON_Call
- func (_c *MockExecutor_DeleteJSON_Call) Return(err error) *MockExecutor_DeleteJSON_Call
- func (_c *MockExecutor_DeleteJSON_Call) Run(run func(ctx context.Context, path string, result any)) *MockExecutor_DeleteJSON_Call
- func (_c *MockExecutor_DeleteJSON_Call) RunAndReturn(run func(ctx context.Context, path string, result any) error) *MockExecutor_DeleteJSON_Call
- type MockExecutor_Delete_Call
- func (_c *MockExecutor_Delete_Call) Return(response *http.Response, err error) *MockExecutor_Delete_Call
- func (_c *MockExecutor_Delete_Call) Run(run func(ctx context.Context, path string)) *MockExecutor_Delete_Call
- func (_c *MockExecutor_Delete_Call) RunAndReturn(run func(ctx context.Context, path string) (*http.Response, error)) *MockExecutor_Delete_Call
- type MockExecutor_DoWithResponse_Call
- type MockExecutor_Do_Call
- type MockExecutor_Expecter
- func (_e *MockExecutor_Expecter) Delete(ctx interface{}, path interface{}) *MockExecutor_Delete_Call
- func (_e *MockExecutor_Expecter) DeleteJSON(ctx interface{}, path interface{}, result interface{}) *MockExecutor_DeleteJSON_Call
- func (_e *MockExecutor_Expecter) Do(ctx interface{}, method interface{}, path interface{}, body interface{}) *MockExecutor_Do_Call
- func (_e *MockExecutor_Expecter) DoWithResponse(ctx interface{}, method interface{}, path interface{}, body interface{}, ...) *MockExecutor_DoWithResponse_Call
- func (_e *MockExecutor_Expecter) Get(ctx interface{}, path interface{}) *MockExecutor_Get_Call
- func (_e *MockExecutor_Expecter) GetErrorParser() *MockExecutor_GetErrorParser_Call
- func (_e *MockExecutor_Expecter) GetHTTPClient() *MockExecutor_GetHTTPClient_Call
- func (_e *MockExecutor_Expecter) GetJSON(ctx interface{}, path interface{}, result interface{}) *MockExecutor_GetJSON_Call
- func (_e *MockExecutor_Expecter) Patch(ctx interface{}, path interface{}, body interface{}) *MockExecutor_Patch_Call
- func (_e *MockExecutor_Expecter) PatchJSON(ctx interface{}, path interface{}, body interface{}, result interface{}) *MockExecutor_PatchJSON_Call
- func (_e *MockExecutor_Expecter) Post(ctx interface{}, path interface{}, body interface{}) *MockExecutor_Post_Call
- func (_e *MockExecutor_Expecter) PostJSON(ctx interface{}, path interface{}, body interface{}, result interface{}) *MockExecutor_PostJSON_Call
- func (_e *MockExecutor_Expecter) Put(ctx interface{}, path interface{}, body interface{}) *MockExecutor_Put_Call
- func (_e *MockExecutor_Expecter) PutJSON(ctx interface{}, path interface{}, body interface{}, result interface{}) *MockExecutor_PutJSON_Call
- func (_e *MockExecutor_Expecter) RemoveHeader(key interface{}) *MockExecutor_RemoveHeader_Call
- func (_e *MockExecutor_Expecter) SetBaseURL(baseURL interface{}) *MockExecutor_SetBaseURL_Call
- func (_e *MockExecutor_Expecter) SetErrorParser(parser interface{}) *MockExecutor_SetErrorParser_Call
- func (_e *MockExecutor_Expecter) SetHTTPClient(httpClient interface{}) *MockExecutor_SetHTTPClient_Call
- func (_e *MockExecutor_Expecter) SetHeader(key interface{}, value interface{}) *MockExecutor_SetHeader_Call
- func (_e *MockExecutor_Expecter) SetHeaders(headers interface{}) *MockExecutor_SetHeaders_Call
- type MockExecutor_GetErrorParser_Call
- func (_c *MockExecutor_GetErrorParser_Call) Return(errorParserChain *ErrorParserChain) *MockExecutor_GetErrorParser_Call
- func (_c *MockExecutor_GetErrorParser_Call) Run(run func()) *MockExecutor_GetErrorParser_Call
- func (_c *MockExecutor_GetErrorParser_Call) RunAndReturn(run func() *ErrorParserChain) *MockExecutor_GetErrorParser_Call
- type MockExecutor_GetHTTPClient_Call
- func (_c *MockExecutor_GetHTTPClient_Call) Return(client *http.Client) *MockExecutor_GetHTTPClient_Call
- func (_c *MockExecutor_GetHTTPClient_Call) Run(run func()) *MockExecutor_GetHTTPClient_Call
- func (_c *MockExecutor_GetHTTPClient_Call) RunAndReturn(run func() *http.Client) *MockExecutor_GetHTTPClient_Call
- type MockExecutor_GetJSON_Call
- func (_c *MockExecutor_GetJSON_Call) Return(err error) *MockExecutor_GetJSON_Call
- func (_c *MockExecutor_GetJSON_Call) Run(run func(ctx context.Context, path string, result any)) *MockExecutor_GetJSON_Call
- func (_c *MockExecutor_GetJSON_Call) RunAndReturn(run func(ctx context.Context, path string, result any) error) *MockExecutor_GetJSON_Call
- type MockExecutor_Get_Call
- func (_c *MockExecutor_Get_Call) Return(response *http.Response, err error) *MockExecutor_Get_Call
- func (_c *MockExecutor_Get_Call) Run(run func(ctx context.Context, path string)) *MockExecutor_Get_Call
- func (_c *MockExecutor_Get_Call) RunAndReturn(run func(ctx context.Context, path string) (*http.Response, error)) *MockExecutor_Get_Call
- type MockExecutor_PatchJSON_Call
- func (_c *MockExecutor_PatchJSON_Call) Return(err error) *MockExecutor_PatchJSON_Call
- func (_c *MockExecutor_PatchJSON_Call) Run(run func(ctx context.Context, path string, body any, result any)) *MockExecutor_PatchJSON_Call
- func (_c *MockExecutor_PatchJSON_Call) RunAndReturn(run func(ctx context.Context, path string, body any, result any) error) *MockExecutor_PatchJSON_Call
- type MockExecutor_Patch_Call
- func (_c *MockExecutor_Patch_Call) Return(response *http.Response, err error) *MockExecutor_Patch_Call
- func (_c *MockExecutor_Patch_Call) Run(run func(ctx context.Context, path string, body any)) *MockExecutor_Patch_Call
- func (_c *MockExecutor_Patch_Call) RunAndReturn(run func(ctx context.Context, path string, body any) (*http.Response, error)) *MockExecutor_Patch_Call
- type MockExecutor_PostJSON_Call
- func (_c *MockExecutor_PostJSON_Call) Return(err error) *MockExecutor_PostJSON_Call
- func (_c *MockExecutor_PostJSON_Call) Run(run func(ctx context.Context, path string, body any, result any)) *MockExecutor_PostJSON_Call
- func (_c *MockExecutor_PostJSON_Call) RunAndReturn(run func(ctx context.Context, path string, body any, result any) error) *MockExecutor_PostJSON_Call
- type MockExecutor_Post_Call
- func (_c *MockExecutor_Post_Call) Return(response *http.Response, err error) *MockExecutor_Post_Call
- func (_c *MockExecutor_Post_Call) Run(run func(ctx context.Context, path string, body any)) *MockExecutor_Post_Call
- func (_c *MockExecutor_Post_Call) RunAndReturn(run func(ctx context.Context, path string, body any) (*http.Response, error)) *MockExecutor_Post_Call
- type MockExecutor_PutJSON_Call
- func (_c *MockExecutor_PutJSON_Call) Return(err error) *MockExecutor_PutJSON_Call
- func (_c *MockExecutor_PutJSON_Call) Run(run func(ctx context.Context, path string, body any, result any)) *MockExecutor_PutJSON_Call
- func (_c *MockExecutor_PutJSON_Call) RunAndReturn(run func(ctx context.Context, path string, body any, result any) error) *MockExecutor_PutJSON_Call
- type MockExecutor_Put_Call
- func (_c *MockExecutor_Put_Call) Return(response *http.Response, err error) *MockExecutor_Put_Call
- func (_c *MockExecutor_Put_Call) Run(run func(ctx context.Context, path string, body any)) *MockExecutor_Put_Call
- func (_c *MockExecutor_Put_Call) RunAndReturn(run func(ctx context.Context, path string, body any) (*http.Response, error)) *MockExecutor_Put_Call
- type MockExecutor_RemoveHeader_Call
- type MockExecutor_SetBaseURL_Call
- type MockExecutor_SetErrorParser_Call
- func (_c *MockExecutor_SetErrorParser_Call) Return() *MockExecutor_SetErrorParser_Call
- func (_c *MockExecutor_SetErrorParser_Call) Run(run func(parser *ErrorParserChain)) *MockExecutor_SetErrorParser_Call
- func (_c *MockExecutor_SetErrorParser_Call) RunAndReturn(run func(parser *ErrorParserChain)) *MockExecutor_SetErrorParser_Call
- type MockExecutor_SetHTTPClient_Call
- func (_c *MockExecutor_SetHTTPClient_Call) Return() *MockExecutor_SetHTTPClient_Call
- func (_c *MockExecutor_SetHTTPClient_Call) Run(run func(httpClient *http.Client)) *MockExecutor_SetHTTPClient_Call
- func (_c *MockExecutor_SetHTTPClient_Call) RunAndReturn(run func(httpClient *http.Client)) *MockExecutor_SetHTTPClient_Call
- type MockExecutor_SetHeader_Call
- func (_c *MockExecutor_SetHeader_Call) Return() *MockExecutor_SetHeader_Call
- func (_c *MockExecutor_SetHeader_Call) Run(run func(key string, value string)) *MockExecutor_SetHeader_Call
- func (_c *MockExecutor_SetHeader_Call) RunAndReturn(run func(key string, value string)) *MockExecutor_SetHeader_Call
- type MockExecutor_SetHeaders_Call
- func (_c *MockExecutor_SetHeaders_Call) Return() *MockExecutor_SetHeaders_Call
- func (_c *MockExecutor_SetHeaders_Call) Run(run func(headers map[string]string)) *MockExecutor_SetHeaders_Call
- func (_c *MockExecutor_SetHeaders_Call) RunAndReturn(run func(headers map[string]string)) *MockExecutor_SetHeaders_Call
- type ParsedErrorResponse
- type RFC7807ErrorParser
- type RateLimiterConfig
- type ResilienceBuilder
- func (rb *ResilienceBuilder) Build() *ResilienceConfig
- func (rb *ResilienceBuilder) WithAdaptiveThrottler(cfg *AdaptiveThrottlerConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithBulkhead(cfg *BulkheadConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithCache(cfg *CacheConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithCircuitBreaker(cfg *CircuitBreakerConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithFallback(cfg *FallbackConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithHedge(cfg *HedgeConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithRateLimiter(cfg *RateLimiterConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithRetryPolicy(cfg *RetryPolicyConfig) *ResilienceBuilder
- func (rb *ResilienceBuilder) WithTimeout(cfg *TimeoutConfig) *ResilienceBuilder
- type ResilienceConfig
- type RetryPolicyConfig
- type StripeErrorParser
- type SumsubErrorParser
- type ThresholdRatio
- type TimeoutConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResilientClient ¶
func NewResilientClient(cfg *ResilienceConfig) *http.Client
NewResilientClient creates an HTTP client with resilience policies This is the recommended way to create a resilient HTTP client
func NewResilientTransport ¶
func NewResilientTransport(baseTransport http.RoundTripper, cfg *ResilienceConfig) http.RoundTripper
NewResilientTransport wraps an existing transport with resilience policies Use this if you need to customize the base transport
Types ¶
type AdaptiveThrottlerConfig ¶ added in v1.3.0
type AdaptiveThrottlerConfig struct {
Enabled bool
FailureRateThreshold float64
MinExecutions uint
Period time.Duration
MaxRejectionRate float64
}
AdaptiveThrottlerConfig limits requests based on failure rate
type BulkheadConfig ¶ added in v1.3.0
BulkheadConfig limits concurrent executions to prevent resource exhaustion
type CacheConfig ¶ added in v1.3.0
CacheConfig provides read-through caching
type CircuitBreakerConfig ¶
type CircuitBreakerConfig struct {
Enabled bool
FailureThreshold uint // Count-based: Opens after N consecutive failures
FailureThresholdRatio *ThresholdRatio // Ratio-based: Opens when X of Y executions fail
SuccessThreshold uint // Count-based: Closes after N consecutive successes in half-open
SuccessThresholdRatio *ThresholdRatio // Ratio-based: Closes when X of Y executions succeed in half-open
Delay time.Duration // Time to wait in open state before half-opening
OnStateChanged func(event circuitbreaker.StateChangedEvent)
OnOpen func(event circuitbreaker.StateChangedEvent)
OnHalfOpen func(event circuitbreaker.StateChangedEvent)
OnClose func(event circuitbreaker.StateChangedEvent)
}
CircuitBreakerConfig holds circuit breaker configuration
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
func NewDefaultClient ¶
func (*Client) DeleteJSON ¶
func (*Client) DoWithResponse ¶
func (*Client) GetErrorParser ¶ added in v1.1.0
func (c *Client) GetErrorParser() *ErrorParserChain
func (*Client) GetHTTPClient ¶
func (*Client) RemoveHeader ¶
func (*Client) SetBaseURL ¶
func (*Client) SetErrorParser ¶ added in v1.1.0
func (c *Client) SetErrorParser(parser *ErrorParserChain)
func (*Client) SetHTTPClient ¶
func (*Client) SetHeaders ¶
type ClientOption ¶
type ClientOption func(*Client)
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
func WithCustomJsonMarshaler ¶ added in v1.3.1
func WithCustomJsonMarshaler(marshal JSONMarshal) ClientOption
WithCustomJsonMarshaler set custom marshal from external packages instead encoding/json. we use encoding/json as default json library due to stability and producibility. However, the standard library is a bit slow compared to 3rd party libraries. If you're not happy with the performance of encoding/json.
supported package: goccy/go-json, bytedance/sonic, segmentio/encoding, minio/simdjson-go, wI2L/jettison, mailru/easyjson.
default is encoding/json
func WithCustomJsonUnmarshaler ¶ added in v1.3.1
func WithCustomJsonUnmarshaler(unmarshal JSONUnmarshal) ClientOption
WithCustomJsonUnmarshaler set custom unmarshal from external packages instead encoding/json. we use encoding/json as default json library due to stability and producibility. However, the standard library is a bit slow compared to 3rd party libraries. If you're not happy with the performance of encoding/json.
supported package: goccy/go-json, bytedance/sonic, segmentio/encoding, minio/simdjson-go, wI2L/jettison, mailru/easyjson.
default is encoding/json
func WithErrorParser ¶ added in v1.1.0
func WithErrorParser(parser ErrorResponseParser) ClientOption
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
func WithHeader ¶
func WithHeader(key, value string) ClientOption
func WithHeaders ¶
func WithHeaders(headers map[string]string) ClientOption
func WithResilienceConfig ¶
func WithResilienceConfig(cfg *ResilienceConfig) ClientOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
type Error ¶
type Error struct {
Type ErrorType `json:"type"`
Message string `json:"message"`
StatusCode int `json:"status_code,omitempty"`
URL string `json:"url"`
Method string `json:"method"`
RequestID string `json:"request_id,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
Err error `json:"-"`
Timestamp time.Time `json:"timestamp"`
ResponseBody []byte `json:"-"`
}
Error represents an HTTP client error with detailed context
func (*Error) GetDetail ¶ added in v1.1.0
GetDetail retrieves a specific detail from the error response
type ErrorParserChain ¶ added in v1.1.0
type ErrorParserChain struct {
// contains filtered or unexported fields
}
ErrorParserChain tries multiple parsers in order
func NewErrorParserChain ¶ added in v1.1.0
func NewErrorParserChain() *ErrorParserChain
func (*ErrorParserChain) AddParser ¶ added in v1.1.0
func (c *ErrorParserChain) AddParser(parser ErrorResponseParser)
func (*ErrorParserChain) Parse ¶ added in v1.1.0
func (c *ErrorParserChain) Parse(body []byte) (*ParsedErrorResponse, error)
type ErrorResponseParser ¶ added in v1.1.0
type ErrorResponseParser interface {
Parse(body []byte) (*ParsedErrorResponse, error)
CanParse(body []byte) bool
}
ErrorResponseParser defines an interface for parsing custom error responses
type Executor ¶ added in v1.1.2
type Executor interface {
Get(ctx context.Context, path string) (*http.Response, error)
Post(ctx context.Context, path string, body any) (*http.Response, error)
Put(ctx context.Context, path string, body any) (*http.Response, error)
Patch(ctx context.Context, path string, body any) (*http.Response, error)
Delete(ctx context.Context, path string) (*http.Response, error)
Do(ctx context.Context, method, path string, body any) (*http.Response, error)
DoWithResponse(ctx context.Context, method, path string, body, result any) error
GetJSON(ctx context.Context, path string, result any) error
PostJSON(ctx context.Context, path string, body, result any) error
PutJSON(ctx context.Context, path string, body, result any) error
PatchJSON(ctx context.Context, path string, body, result any) error
DeleteJSON(ctx context.Context, path string, result any) error
GetErrorParser() *ErrorParserChain
SetErrorParser(parser *ErrorParserChain)
SetBaseURL(baseURL string)
SetHeader(key, value string)
SetHeaders(headers map[string]string)
RemoveHeader(key string)
GetHTTPClient() *http.Client
SetHTTPClient(httpClient *http.Client)
}
type FallbackConfig ¶
type FallbackConfig struct {
Enabled bool
FallbackFunc func(exec failsafe.Execution[*http.Response]) (*http.Response, error)
OnFallbackExecuted func(event failsafe.ExecutionDoneEvent[*http.Response])
}
FallbackConfig holds fallback configuration
type GenericErrorParser ¶ added in v1.1.0
type GenericErrorParser struct{}
GenericErrorParser parses common error response formats
func (*GenericErrorParser) CanParse ¶ added in v1.1.0
func (p *GenericErrorParser) CanParse(body []byte) bool
func (*GenericErrorParser) Parse ¶ added in v1.1.0
func (p *GenericErrorParser) Parse(body []byte) (*ParsedErrorResponse, error)
type HedgeConfig ¶ added in v1.3.0
type HedgeConfig struct {
Enabled bool
Delay time.Duration
MaxHedges int
CancelOnResult bool // Cancel outstanding hedges once a result is received
}
HedgeConfig handles tail latency by sending backup requests
type JSONMarshal ¶ added in v1.3.1
JSONMarshal returns the JSON encoding of v.
type JSONUnmarshal ¶ added in v1.3.1
JSONUnmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.
type MockErrorResponseParser ¶ added in v1.1.3
MockErrorResponseParser is an autogenerated mock type for the ErrorResponseParser type
func NewMockErrorResponseParser ¶ added in v1.1.3
func NewMockErrorResponseParser(t interface {
mock.TestingT
Cleanup(func())
}) *MockErrorResponseParser
NewMockErrorResponseParser creates a new instance of MockErrorResponseParser. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockErrorResponseParser) CanParse ¶ added in v1.1.3
func (_mock *MockErrorResponseParser) CanParse(body []byte) bool
CanParse provides a mock function for the type MockErrorResponseParser
func (*MockErrorResponseParser) EXPECT ¶ added in v1.1.3
func (_m *MockErrorResponseParser) EXPECT() *MockErrorResponseParser_Expecter
func (*MockErrorResponseParser) Parse ¶ added in v1.1.3
func (_mock *MockErrorResponseParser) Parse(body []byte) (*ParsedErrorResponse, error)
Parse provides a mock function for the type MockErrorResponseParser
type MockErrorResponseParser_CanParse_Call ¶ added in v1.1.3
MockErrorResponseParser_CanParse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CanParse'
func (*MockErrorResponseParser_CanParse_Call) Return ¶ added in v1.1.3
func (_c *MockErrorResponseParser_CanParse_Call) Return(b bool) *MockErrorResponseParser_CanParse_Call
func (*MockErrorResponseParser_CanParse_Call) Run ¶ added in v1.1.3
func (_c *MockErrorResponseParser_CanParse_Call) Run(run func(body []byte)) *MockErrorResponseParser_CanParse_Call
func (*MockErrorResponseParser_CanParse_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockErrorResponseParser_CanParse_Call) RunAndReturn(run func(body []byte) bool) *MockErrorResponseParser_CanParse_Call
type MockErrorResponseParser_Expecter ¶ added in v1.1.3
type MockErrorResponseParser_Expecter struct {
// contains filtered or unexported fields
}
func (*MockErrorResponseParser_Expecter) CanParse ¶ added in v1.1.3
func (_e *MockErrorResponseParser_Expecter) CanParse(body interface{}) *MockErrorResponseParser_CanParse_Call
CanParse is a helper method to define mock.On call
- body []byte
func (*MockErrorResponseParser_Expecter) Parse ¶ added in v1.1.3
func (_e *MockErrorResponseParser_Expecter) Parse(body interface{}) *MockErrorResponseParser_Parse_Call
Parse is a helper method to define mock.On call
- body []byte
type MockErrorResponseParser_Parse_Call ¶ added in v1.1.3
MockErrorResponseParser_Parse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Parse'
func (*MockErrorResponseParser_Parse_Call) Return ¶ added in v1.1.3
func (_c *MockErrorResponseParser_Parse_Call) Return(parsedErrorResponse *ParsedErrorResponse, err error) *MockErrorResponseParser_Parse_Call
func (*MockErrorResponseParser_Parse_Call) Run ¶ added in v1.1.3
func (_c *MockErrorResponseParser_Parse_Call) Run(run func(body []byte)) *MockErrorResponseParser_Parse_Call
func (*MockErrorResponseParser_Parse_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockErrorResponseParser_Parse_Call) RunAndReturn(run func(body []byte) (*ParsedErrorResponse, error)) *MockErrorResponseParser_Parse_Call
type MockExecutor ¶ added in v1.1.3
MockExecutor is an autogenerated mock type for the Executor type
func NewMockExecutor ¶ added in v1.1.3
func NewMockExecutor(t interface {
mock.TestingT
Cleanup(func())
}) *MockExecutor
NewMockExecutor creates a new instance of MockExecutor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockExecutor) Delete ¶ added in v1.1.3
Delete provides a mock function for the type MockExecutor
func (*MockExecutor) DeleteJSON ¶ added in v1.1.3
DeleteJSON provides a mock function for the type MockExecutor
func (*MockExecutor) Do ¶ added in v1.1.3
func (_mock *MockExecutor) Do(ctx context.Context, method string, path string, body any) (*http.Response, error)
Do provides a mock function for the type MockExecutor
func (*MockExecutor) DoWithResponse ¶ added in v1.1.3
func (_mock *MockExecutor) DoWithResponse(ctx context.Context, method string, path string, body any, result any) error
DoWithResponse provides a mock function for the type MockExecutor
func (*MockExecutor) EXPECT ¶ added in v1.1.3
func (_m *MockExecutor) EXPECT() *MockExecutor_Expecter
func (*MockExecutor) GetErrorParser ¶ added in v1.1.3
func (_mock *MockExecutor) GetErrorParser() *ErrorParserChain
GetErrorParser provides a mock function for the type MockExecutor
func (*MockExecutor) GetHTTPClient ¶ added in v1.1.3
func (_mock *MockExecutor) GetHTTPClient() *http.Client
GetHTTPClient provides a mock function for the type MockExecutor
func (*MockExecutor) GetJSON ¶ added in v1.1.3
GetJSON provides a mock function for the type MockExecutor
func (*MockExecutor) Patch ¶ added in v1.1.3
func (_mock *MockExecutor) Patch(ctx context.Context, path string, body any) (*http.Response, error)
Patch provides a mock function for the type MockExecutor
func (*MockExecutor) PatchJSON ¶ added in v1.1.3
PatchJSON provides a mock function for the type MockExecutor
func (*MockExecutor) PostJSON ¶ added in v1.1.3
PostJSON provides a mock function for the type MockExecutor
func (*MockExecutor) PutJSON ¶ added in v1.1.3
PutJSON provides a mock function for the type MockExecutor
func (*MockExecutor) RemoveHeader ¶ added in v1.1.3
func (_mock *MockExecutor) RemoveHeader(key string)
RemoveHeader provides a mock function for the type MockExecutor
func (*MockExecutor) SetBaseURL ¶ added in v1.1.3
func (_mock *MockExecutor) SetBaseURL(baseURL string)
SetBaseURL provides a mock function for the type MockExecutor
func (*MockExecutor) SetErrorParser ¶ added in v1.1.3
func (_mock *MockExecutor) SetErrorParser(parser *ErrorParserChain)
SetErrorParser provides a mock function for the type MockExecutor
func (*MockExecutor) SetHTTPClient ¶ added in v1.1.3
func (_mock *MockExecutor) SetHTTPClient(httpClient *http.Client)
SetHTTPClient provides a mock function for the type MockExecutor
func (*MockExecutor) SetHeader ¶ added in v1.1.3
func (_mock *MockExecutor) SetHeader(key string, value string)
SetHeader provides a mock function for the type MockExecutor
func (*MockExecutor) SetHeaders ¶ added in v1.1.3
func (_mock *MockExecutor) SetHeaders(headers map[string]string)
SetHeaders provides a mock function for the type MockExecutor
type MockExecutor_DeleteJSON_Call ¶ added in v1.1.3
MockExecutor_DeleteJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteJSON'
func (*MockExecutor_DeleteJSON_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_DeleteJSON_Call) Return(err error) *MockExecutor_DeleteJSON_Call
func (*MockExecutor_DeleteJSON_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_DeleteJSON_Call) Run(run func(ctx context.Context, path string, result any)) *MockExecutor_DeleteJSON_Call
func (*MockExecutor_DeleteJSON_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_DeleteJSON_Call) RunAndReturn(run func(ctx context.Context, path string, result any) error) *MockExecutor_DeleteJSON_Call
type MockExecutor_Delete_Call ¶ added in v1.1.3
MockExecutor_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete'
func (*MockExecutor_Delete_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_Delete_Call) Return(response *http.Response, err error) *MockExecutor_Delete_Call
func (*MockExecutor_Delete_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_Delete_Call) Run(run func(ctx context.Context, path string)) *MockExecutor_Delete_Call
func (*MockExecutor_Delete_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_Delete_Call) RunAndReturn(run func(ctx context.Context, path string) (*http.Response, error)) *MockExecutor_Delete_Call
type MockExecutor_DoWithResponse_Call ¶ added in v1.1.3
MockExecutor_DoWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoWithResponse'
func (*MockExecutor_DoWithResponse_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_DoWithResponse_Call) Return(err error) *MockExecutor_DoWithResponse_Call
func (*MockExecutor_DoWithResponse_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_DoWithResponse_Call) Run(run func(ctx context.Context, method string, path string, body any, result any)) *MockExecutor_DoWithResponse_Call
func (*MockExecutor_DoWithResponse_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_DoWithResponse_Call) RunAndReturn(run func(ctx context.Context, method string, path string, body any, result any) error) *MockExecutor_DoWithResponse_Call
type MockExecutor_Do_Call ¶ added in v1.1.3
MockExecutor_Do_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Do'
func (*MockExecutor_Do_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_Do_Call) Return(response *http.Response, err error) *MockExecutor_Do_Call
func (*MockExecutor_Do_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_Do_Call) Run(run func(ctx context.Context, method string, path string, body any)) *MockExecutor_Do_Call
func (*MockExecutor_Do_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_Do_Call) RunAndReturn(run func(ctx context.Context, method string, path string, body any) (*http.Response, error)) *MockExecutor_Do_Call
type MockExecutor_Expecter ¶ added in v1.1.3
type MockExecutor_Expecter struct {
// contains filtered or unexported fields
}
func (*MockExecutor_Expecter) Delete ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) Delete(ctx interface{}, path interface{}) *MockExecutor_Delete_Call
Delete is a helper method to define mock.On call
- ctx context.Context
- path string
func (*MockExecutor_Expecter) DeleteJSON ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) DeleteJSON(ctx interface{}, path interface{}, result interface{}) *MockExecutor_DeleteJSON_Call
DeleteJSON is a helper method to define mock.On call
- ctx context.Context
- path string
- result any
func (*MockExecutor_Expecter) Do ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) Do(ctx interface{}, method interface{}, path interface{}, body interface{}) *MockExecutor_Do_Call
Do is a helper method to define mock.On call
- ctx context.Context
- method string
- path string
- body any
func (*MockExecutor_Expecter) DoWithResponse ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) DoWithResponse(ctx interface{}, method interface{}, path interface{}, body interface{}, result interface{}) *MockExecutor_DoWithResponse_Call
DoWithResponse is a helper method to define mock.On call
- ctx context.Context
- method string
- path string
- body any
- result any
func (*MockExecutor_Expecter) Get ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) Get(ctx interface{}, path interface{}) *MockExecutor_Get_Call
Get is a helper method to define mock.On call
- ctx context.Context
- path string
func (*MockExecutor_Expecter) GetErrorParser ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) GetErrorParser() *MockExecutor_GetErrorParser_Call
GetErrorParser is a helper method to define mock.On call
func (*MockExecutor_Expecter) GetHTTPClient ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) GetHTTPClient() *MockExecutor_GetHTTPClient_Call
GetHTTPClient is a helper method to define mock.On call
func (*MockExecutor_Expecter) GetJSON ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) GetJSON(ctx interface{}, path interface{}, result interface{}) *MockExecutor_GetJSON_Call
GetJSON is a helper method to define mock.On call
- ctx context.Context
- path string
- result any
func (*MockExecutor_Expecter) Patch ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) Patch(ctx interface{}, path interface{}, body interface{}) *MockExecutor_Patch_Call
Patch is a helper method to define mock.On call
- ctx context.Context
- path string
- body any
func (*MockExecutor_Expecter) PatchJSON ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) PatchJSON(ctx interface{}, path interface{}, body interface{}, result interface{}) *MockExecutor_PatchJSON_Call
PatchJSON is a helper method to define mock.On call
- ctx context.Context
- path string
- body any
- result any
func (*MockExecutor_Expecter) Post ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) Post(ctx interface{}, path interface{}, body interface{}) *MockExecutor_Post_Call
Post is a helper method to define mock.On call
- ctx context.Context
- path string
- body any
func (*MockExecutor_Expecter) PostJSON ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) PostJSON(ctx interface{}, path interface{}, body interface{}, result interface{}) *MockExecutor_PostJSON_Call
PostJSON is a helper method to define mock.On call
- ctx context.Context
- path string
- body any
- result any
func (*MockExecutor_Expecter) Put ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) Put(ctx interface{}, path interface{}, body interface{}) *MockExecutor_Put_Call
Put is a helper method to define mock.On call
- ctx context.Context
- path string
- body any
func (*MockExecutor_Expecter) PutJSON ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) PutJSON(ctx interface{}, path interface{}, body interface{}, result interface{}) *MockExecutor_PutJSON_Call
PutJSON is a helper method to define mock.On call
- ctx context.Context
- path string
- body any
- result any
func (*MockExecutor_Expecter) RemoveHeader ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) RemoveHeader(key interface{}) *MockExecutor_RemoveHeader_Call
RemoveHeader is a helper method to define mock.On call
- key string
func (*MockExecutor_Expecter) SetBaseURL ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) SetBaseURL(baseURL interface{}) *MockExecutor_SetBaseURL_Call
SetBaseURL is a helper method to define mock.On call
- baseURL string
func (*MockExecutor_Expecter) SetErrorParser ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) SetErrorParser(parser interface{}) *MockExecutor_SetErrorParser_Call
SetErrorParser is a helper method to define mock.On call
- parser *ErrorParserChain
func (*MockExecutor_Expecter) SetHTTPClient ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) SetHTTPClient(httpClient interface{}) *MockExecutor_SetHTTPClient_Call
SetHTTPClient is a helper method to define mock.On call
- httpClient *http.Client
func (*MockExecutor_Expecter) SetHeader ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) SetHeader(key interface{}, value interface{}) *MockExecutor_SetHeader_Call
SetHeader is a helper method to define mock.On call
- key string
- value string
func (*MockExecutor_Expecter) SetHeaders ¶ added in v1.1.3
func (_e *MockExecutor_Expecter) SetHeaders(headers interface{}) *MockExecutor_SetHeaders_Call
SetHeaders is a helper method to define mock.On call
- headers map[string]string
type MockExecutor_GetErrorParser_Call ¶ added in v1.1.3
MockExecutor_GetErrorParser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetErrorParser'
func (*MockExecutor_GetErrorParser_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_GetErrorParser_Call) Return(errorParserChain *ErrorParserChain) *MockExecutor_GetErrorParser_Call
func (*MockExecutor_GetErrorParser_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_GetErrorParser_Call) Run(run func()) *MockExecutor_GetErrorParser_Call
func (*MockExecutor_GetErrorParser_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_GetErrorParser_Call) RunAndReturn(run func() *ErrorParserChain) *MockExecutor_GetErrorParser_Call
type MockExecutor_GetHTTPClient_Call ¶ added in v1.1.3
MockExecutor_GetHTTPClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetHTTPClient'
func (*MockExecutor_GetHTTPClient_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_GetHTTPClient_Call) Return(client *http.Client) *MockExecutor_GetHTTPClient_Call
func (*MockExecutor_GetHTTPClient_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_GetHTTPClient_Call) Run(run func()) *MockExecutor_GetHTTPClient_Call
func (*MockExecutor_GetHTTPClient_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_GetHTTPClient_Call) RunAndReturn(run func() *http.Client) *MockExecutor_GetHTTPClient_Call
type MockExecutor_GetJSON_Call ¶ added in v1.1.3
MockExecutor_GetJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJSON'
func (*MockExecutor_GetJSON_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_GetJSON_Call) Return(err error) *MockExecutor_GetJSON_Call
func (*MockExecutor_GetJSON_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_GetJSON_Call) Run(run func(ctx context.Context, path string, result any)) *MockExecutor_GetJSON_Call
func (*MockExecutor_GetJSON_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_GetJSON_Call) RunAndReturn(run func(ctx context.Context, path string, result any) error) *MockExecutor_GetJSON_Call
type MockExecutor_Get_Call ¶ added in v1.1.3
MockExecutor_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
func (*MockExecutor_Get_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_Get_Call) Return(response *http.Response, err error) *MockExecutor_Get_Call
func (*MockExecutor_Get_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_Get_Call) Run(run func(ctx context.Context, path string)) *MockExecutor_Get_Call
func (*MockExecutor_Get_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_Get_Call) RunAndReturn(run func(ctx context.Context, path string) (*http.Response, error)) *MockExecutor_Get_Call
type MockExecutor_PatchJSON_Call ¶ added in v1.1.3
MockExecutor_PatchJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PatchJSON'
func (*MockExecutor_PatchJSON_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_PatchJSON_Call) Return(err error) *MockExecutor_PatchJSON_Call
func (*MockExecutor_PatchJSON_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_PatchJSON_Call) Run(run func(ctx context.Context, path string, body any, result any)) *MockExecutor_PatchJSON_Call
func (*MockExecutor_PatchJSON_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_PatchJSON_Call) RunAndReturn(run func(ctx context.Context, path string, body any, result any) error) *MockExecutor_PatchJSON_Call
type MockExecutor_Patch_Call ¶ added in v1.1.3
MockExecutor_Patch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Patch'
func (*MockExecutor_Patch_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_Patch_Call) Return(response *http.Response, err error) *MockExecutor_Patch_Call
func (*MockExecutor_Patch_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_Patch_Call) Run(run func(ctx context.Context, path string, body any)) *MockExecutor_Patch_Call
func (*MockExecutor_Patch_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_Patch_Call) RunAndReturn(run func(ctx context.Context, path string, body any) (*http.Response, error)) *MockExecutor_Patch_Call
type MockExecutor_PostJSON_Call ¶ added in v1.1.3
MockExecutor_PostJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PostJSON'
func (*MockExecutor_PostJSON_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_PostJSON_Call) Return(err error) *MockExecutor_PostJSON_Call
func (*MockExecutor_PostJSON_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_PostJSON_Call) Run(run func(ctx context.Context, path string, body any, result any)) *MockExecutor_PostJSON_Call
func (*MockExecutor_PostJSON_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_PostJSON_Call) RunAndReturn(run func(ctx context.Context, path string, body any, result any) error) *MockExecutor_PostJSON_Call
type MockExecutor_Post_Call ¶ added in v1.1.3
MockExecutor_Post_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Post'
func (*MockExecutor_Post_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_Post_Call) Return(response *http.Response, err error) *MockExecutor_Post_Call
func (*MockExecutor_Post_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_Post_Call) Run(run func(ctx context.Context, path string, body any)) *MockExecutor_Post_Call
func (*MockExecutor_Post_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_Post_Call) RunAndReturn(run func(ctx context.Context, path string, body any) (*http.Response, error)) *MockExecutor_Post_Call
type MockExecutor_PutJSON_Call ¶ added in v1.1.3
MockExecutor_PutJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PutJSON'
func (*MockExecutor_PutJSON_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_PutJSON_Call) Return(err error) *MockExecutor_PutJSON_Call
func (*MockExecutor_PutJSON_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_PutJSON_Call) Run(run func(ctx context.Context, path string, body any, result any)) *MockExecutor_PutJSON_Call
func (*MockExecutor_PutJSON_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_PutJSON_Call) RunAndReturn(run func(ctx context.Context, path string, body any, result any) error) *MockExecutor_PutJSON_Call
type MockExecutor_Put_Call ¶ added in v1.1.3
MockExecutor_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put'
func (*MockExecutor_Put_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_Put_Call) Return(response *http.Response, err error) *MockExecutor_Put_Call
func (*MockExecutor_Put_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_Put_Call) Run(run func(ctx context.Context, path string, body any)) *MockExecutor_Put_Call
func (*MockExecutor_Put_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_Put_Call) RunAndReturn(run func(ctx context.Context, path string, body any) (*http.Response, error)) *MockExecutor_Put_Call
type MockExecutor_RemoveHeader_Call ¶ added in v1.1.3
MockExecutor_RemoveHeader_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveHeader'
func (*MockExecutor_RemoveHeader_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_RemoveHeader_Call) Return() *MockExecutor_RemoveHeader_Call
func (*MockExecutor_RemoveHeader_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_RemoveHeader_Call) Run(run func(key string)) *MockExecutor_RemoveHeader_Call
func (*MockExecutor_RemoveHeader_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_RemoveHeader_Call) RunAndReturn(run func(key string)) *MockExecutor_RemoveHeader_Call
type MockExecutor_SetBaseURL_Call ¶ added in v1.1.3
MockExecutor_SetBaseURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetBaseURL'
func (*MockExecutor_SetBaseURL_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_SetBaseURL_Call) Return() *MockExecutor_SetBaseURL_Call
func (*MockExecutor_SetBaseURL_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_SetBaseURL_Call) Run(run func(baseURL string)) *MockExecutor_SetBaseURL_Call
func (*MockExecutor_SetBaseURL_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_SetBaseURL_Call) RunAndReturn(run func(baseURL string)) *MockExecutor_SetBaseURL_Call
type MockExecutor_SetErrorParser_Call ¶ added in v1.1.3
MockExecutor_SetErrorParser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetErrorParser'
func (*MockExecutor_SetErrorParser_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_SetErrorParser_Call) Return() *MockExecutor_SetErrorParser_Call
func (*MockExecutor_SetErrorParser_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_SetErrorParser_Call) Run(run func(parser *ErrorParserChain)) *MockExecutor_SetErrorParser_Call
func (*MockExecutor_SetErrorParser_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_SetErrorParser_Call) RunAndReturn(run func(parser *ErrorParserChain)) *MockExecutor_SetErrorParser_Call
type MockExecutor_SetHTTPClient_Call ¶ added in v1.1.3
MockExecutor_SetHTTPClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetHTTPClient'
func (*MockExecutor_SetHTTPClient_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_SetHTTPClient_Call) Return() *MockExecutor_SetHTTPClient_Call
func (*MockExecutor_SetHTTPClient_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_SetHTTPClient_Call) Run(run func(httpClient *http.Client)) *MockExecutor_SetHTTPClient_Call
func (*MockExecutor_SetHTTPClient_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_SetHTTPClient_Call) RunAndReturn(run func(httpClient *http.Client)) *MockExecutor_SetHTTPClient_Call
type MockExecutor_SetHeader_Call ¶ added in v1.1.3
MockExecutor_SetHeader_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetHeader'
func (*MockExecutor_SetHeader_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_SetHeader_Call) Return() *MockExecutor_SetHeader_Call
func (*MockExecutor_SetHeader_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_SetHeader_Call) Run(run func(key string, value string)) *MockExecutor_SetHeader_Call
func (*MockExecutor_SetHeader_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_SetHeader_Call) RunAndReturn(run func(key string, value string)) *MockExecutor_SetHeader_Call
type MockExecutor_SetHeaders_Call ¶ added in v1.1.3
MockExecutor_SetHeaders_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetHeaders'
func (*MockExecutor_SetHeaders_Call) Return ¶ added in v1.1.3
func (_c *MockExecutor_SetHeaders_Call) Return() *MockExecutor_SetHeaders_Call
func (*MockExecutor_SetHeaders_Call) Run ¶ added in v1.1.3
func (_c *MockExecutor_SetHeaders_Call) Run(run func(headers map[string]string)) *MockExecutor_SetHeaders_Call
func (*MockExecutor_SetHeaders_Call) RunAndReturn ¶ added in v1.1.3
func (_c *MockExecutor_SetHeaders_Call) RunAndReturn(run func(headers map[string]string)) *MockExecutor_SetHeaders_Call
type ParsedErrorResponse ¶ added in v1.1.0
type ParsedErrorResponse struct {
Message string
ErrorCode string
CorrelationID string
Details map[string]interface{}
}
ParsedErrorResponse represents a parsed error response from an external API
type RFC7807ErrorParser ¶ added in v1.1.0
type RFC7807ErrorParser struct {
GenericErrorParser
}
RFC7807ErrorParser parses RFC 7807 Problem Details for HTTP APIs
func (*RFC7807ErrorParser) CanParse ¶ added in v1.1.0
func (p *RFC7807ErrorParser) CanParse(body []byte) bool
func (*RFC7807ErrorParser) Parse ¶ added in v1.1.0
func (p *RFC7807ErrorParser) Parse(body []byte) (*ParsedErrorResponse, error)
type RateLimiterConfig ¶ added in v1.3.0
type RateLimiterConfig struct {
Enabled bool
MaxExecutions uint
Period time.Duration
MaxWaitTime time.Duration
IsBursty bool // If true, uses fixed window; else uses smooth leaky bucket
}
RateLimiterConfig holds rate limiter configuration
type ResilienceBuilder ¶
type ResilienceBuilder struct {
// contains filtered or unexported fields
}
ResilienceBuilder builds resilience configurations using fluent API
func NewResilienceBuilder ¶
func NewResilienceBuilder() *ResilienceBuilder
NewResilienceBuilder creates a new resilience configuration builder
func (*ResilienceBuilder) Build ¶
func (rb *ResilienceBuilder) Build() *ResilienceConfig
Build constructs the final resilience configuration
func (*ResilienceBuilder) WithAdaptiveThrottler ¶ added in v1.3.0
func (rb *ResilienceBuilder) WithAdaptiveThrottler(cfg *AdaptiveThrottlerConfig) *ResilienceBuilder
func (*ResilienceBuilder) WithBulkhead ¶ added in v1.3.0
func (rb *ResilienceBuilder) WithBulkhead(cfg *BulkheadConfig) *ResilienceBuilder
func (*ResilienceBuilder) WithCache ¶ added in v1.3.0
func (rb *ResilienceBuilder) WithCache(cfg *CacheConfig) *ResilienceBuilder
func (*ResilienceBuilder) WithCircuitBreaker ¶
func (rb *ResilienceBuilder) WithCircuitBreaker(cfg *CircuitBreakerConfig) *ResilienceBuilder
WithCircuitBreaker configures circuit breaker settings
func (*ResilienceBuilder) WithFallback ¶
func (rb *ResilienceBuilder) WithFallback(cfg *FallbackConfig) *ResilienceBuilder
WithFallback configures fallback settings
func (*ResilienceBuilder) WithHedge ¶ added in v1.3.0
func (rb *ResilienceBuilder) WithHedge(cfg *HedgeConfig) *ResilienceBuilder
func (*ResilienceBuilder) WithRateLimiter ¶ added in v1.3.0
func (rb *ResilienceBuilder) WithRateLimiter(cfg *RateLimiterConfig) *ResilienceBuilder
func (*ResilienceBuilder) WithRetryPolicy ¶
func (rb *ResilienceBuilder) WithRetryPolicy(cfg *RetryPolicyConfig) *ResilienceBuilder
WithRetryPolicy configures retry policy settings
func (*ResilienceBuilder) WithTimeout ¶
func (rb *ResilienceBuilder) WithTimeout(cfg *TimeoutConfig) *ResilienceBuilder
WithTimeout configures timeout settings
type ResilienceConfig ¶
type ResilienceConfig struct {
CircuitBreaker *CircuitBreakerConfig
RetryPolicy *RetryPolicyConfig
Timeout *TimeoutConfig
Fallback *FallbackConfig
RateLimiter *RateLimiterConfig
Bulkhead *BulkheadConfig
Hedge *HedgeConfig
AdaptiveThrottler *AdaptiveThrottlerConfig
Cache *CacheConfig
}
ResilienceConfig updated with new policies
func DefaultResilienceConfig ¶
func DefaultResilienceConfig() *ResilienceConfig
DefaultResilienceConfig returns a production-ready default configuration
type RetryPolicyConfig ¶
type RetryPolicyConfig struct {
Enabled bool
MaxAttempts int // Maximum number of execution attempts (initial + retries)
MaxRetries int // Maximum number of retries (MaxAttempts - 1)
MaxDuration time.Duration // Maximum total duration for all attempts
Delay time.Duration // Fixed delay between retries
BackoffInitial time.Duration // Initial delay for exponential backoff
BackoffMax time.Duration // Maximum delay for exponential backoff
RandomDelayMin time.Duration // Minimum random delay
RandomDelayMax time.Duration // Maximum random delay
JitterFactor float64 // Jitter factor (0-1) to add randomness to delays
Jitter time.Duration // Time-based jitter to add to delays
RetryableStatus []int // HTTP status codes that should trigger a retry
AbortOnStatus []int // HTTP status codes that should abort retries immediately
OnRetry func(event failsafe.ExecutionEvent[*http.Response])
OnRetriesExceeded func(event failsafe.ExecutionEvent[*http.Response])
OnAbort func(event failsafe.ExecutionEvent[*http.Response])
}
RetryPolicyConfig holds retry policy configuration
type StripeErrorParser ¶ added in v1.1.0
type StripeErrorParser struct {
GenericErrorParser
}
StripeErrorParser parses Stripe-specific error responses
func (*StripeErrorParser) CanParse ¶ added in v1.1.0
func (p *StripeErrorParser) CanParse(body []byte) bool
func (*StripeErrorParser) Parse ¶ added in v1.1.0
func (p *StripeErrorParser) Parse(body []byte) (*ParsedErrorResponse, error)
type SumsubErrorParser ¶ added in v1.1.0
type SumsubErrorParser struct {
GenericErrorParser
}
SumsubErrorParser parses Sumsub-specific error responses
func (*SumsubErrorParser) CanParse ¶ added in v1.1.0
func (p *SumsubErrorParser) CanParse(body []byte) bool
func (*SumsubErrorParser) Parse ¶ added in v1.1.0
func (p *SumsubErrorParser) Parse(body []byte) (*ParsedErrorResponse, error)
type ThresholdRatio ¶
ThresholdRatio represents a ratio-based threshold (e.g., 3 failures out of 5 total)
type TimeoutConfig ¶
type TimeoutConfig struct {
Enabled bool
Duration time.Duration // Maximum time allowed for execution
OnTimeoutExceeded func(event failsafe.ExecutionDoneEvent[*http.Response])
}
TimeoutConfig holds timeout configuration