Documentation
¶
Index ¶
- Variables
- type Conf
- type Dialer
- type NetworkConf
- type Option
- func WithCustomValidator(fn func(context.Context, *http.Request, *http.Response, error) error) Option
- func WithDefaultExecutor() Option
- func WithDefaultValidators() Option
- func WithRequestOption(fn RequestOption) Option
- func WithResponseOption(fn ResponseOption) Option
- func WithRetrierExecutor(logger log.Logger, opts ...retrier.RetrierOption) Option
- func WithRoundTripperExecutor(cfg *Conf) Option
- func WithTimeoutExecutor(cfg *TimeoutConf) Option
- type RequestOption
- type ResponseOption
- type TimeoutConf
- type TransportConf
Constants ¶
This section is empty.
Variables ¶
var ( ErrResponseIsNil = errors.New("'response' from downstream is nil") ErrExec = errors.New("executor failed") )
Error response
var ( ErrInternalServer = errors.New("internal server error, response code > 500") ErrNotFound = errors.New("resource not found, response code = 404") )
Validator Errors
Functions ¶
This section is empty.
Types ¶
type Conf ¶
type Conf struct { Tr TransportConf Nw NetworkConf To TimeoutConf }
type Dialer ¶
Dialer interface defines the dialer for a downstream request
func NewDefaultDialer ¶
NewDefaultDialer returns new default http dialer
type NetworkConf ¶
type NetworkConf struct { // Timeout is the maximum amount of time a dial will wait for // a connect to complete. If Deadline is also set, it may fail // earlier. // // The default is no timeout. // // When using TCP and dialing a host name with multiple IP // addresses, the timeout may be divided between them. // // With or without a timeout, the operating system may impose // its own earlier timeout. For instance, TCP timeouts are // often around 3 minutes. Timeout int // KeepAlive specifies the keep-alive period for an active // network connection. // If zero, keep-alives are enabled if supported by the protocol // and operating system. Network protocols or operating systems // that do not support keep-alives ignore this field. // If negative, keep-alives are disabled. KeepAlive int }
type Option ¶
type Option func(*defaultDialer) error
Option sets optional parameters for dailer
func WithCustomValidator ¶
func WithCustomValidator( fn func( context.Context, *http.Request, *http.Response, error, ) error, ) Option
WithCustomValidator sets custom validator to list of existing validator
func WithDefaultExecutor ¶
func WithDefaultExecutor() Option
WithDefaultExecutor uses default http.DefaultTransport for round trip
func WithDefaultValidators ¶
func WithDefaultValidators() Option
WithDefaultValidators sets the validators for the dialer
func WithRequestOption ¶
func WithRequestOption(fn RequestOption) Option
WithRequestOption sets a custom request option for request
func WithResponseOption ¶
func WithResponseOption(fn ResponseOption) Option
WithResponseOption sets a custom response option for request
func WithRetrierExecutor ¶ added in v1.0.2
func WithRetrierExecutor( logger log.Logger, opts ...retrier.RetrierOption, ) Option
func WithRoundTripperExecutor ¶
WithRoundTripperExecutor executor which uses a custom round tripper built from configurations to call downstream
func WithTimeoutExecutor ¶
func WithTimeoutExecutor(cfg *TimeoutConf) Option
WithTimeoutExecutor sets a custom executor which has very short timeout
type TimeoutConf ¶
type TimeoutConf struct {
Tm int //in millisecond
}
type TransportConf ¶
type TransportConf struct { // MaxIdleConns controls the maximum number of idle (keep-alive) // connections across all hosts. Zero means no limit. MaxIdleConns int // MaxIdleConnsPerHost, if non-zero, controls the maximum idle // (keep-alive) connections to keep per-host. MaxIdleConnsPerHost int // MaxConnsPerHost optionally limits the total number of // connections per host, including connections in the dialing, // active, and idle states. On limit violation, dials will block. // // Zero means no limit. MaxConnsPerHost int // IdleConnTimeout is the maximum amount of time an idle // IdleConnTimeout is the maximum amount of time an idle // itself. // Zero means no limit. IdleConnTimeout int }