Documentation ¶
Index ¶
- Variables
- func Debugf(format string, args ...interface{})
- func HttpClientClusterDo(request *http.Request) (*http.Response, error)
- func RegLog(logger Log)
- func SetClientConfig(scheme, host string, cfg *HttpClusterConfig) error
- func SetDefaultConfig(defaultRetry int, defaultRequestTimeout time.Duration) error
- func SetRedirect(ok bool)
- type ClusterError
- type ConfigClient
- type HttpClusterClient
- func (c *HttpClusterClient) Do(request *http.Request) (*http.Response, error)
- func (c *HttpClusterClient) DoRequest(request *http.Request) (*http.Response, error)
- func (c *HttpClusterClient) Len() int
- func (c *HttpClusterClient) Less(i, j int) bool
- func (c *HttpClusterClient) Pop() (client interface{})
- func (c *HttpClusterClient) Push(client interface{})
- func (c *HttpClusterClient) Swap(i, j int)
- type HttpClusterConfig
- type Log
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoEndpoints = errors.New("client: no endpoints available") ErrTooManyRedirects = errors.New("client: too many redirects") ErrNoLeaderEndpoint = errors.New("client: no leader endpoint available") )
View Source
var ClientMap map[string]ConfigClient = make(map[string]ConfigClient, 1)
per host to a client
View Source
var DefaultRequestTimeout = 10 * time.Second
View Source
var DefaultRetry = 1
View Source
var Redirect = true
Functions ¶
func HttpClientClusterDo ¶
the Response.Body has closed after reading into body.
func SetClientConfig ¶
func SetClientConfig(scheme, host string, cfg *HttpClusterConfig) error
func SetDefaultConfig ¶
eg SetDefaultConfig(1, 120*time.Second)
func SetRedirect ¶
func SetRedirect(ok bool)
Types ¶
type ClusterError ¶
type ClusterError struct {
Errors []error
}
func (*ClusterError) Detail ¶
func (ce *ClusterError) Detail() string
func (*ClusterError) Error ¶
func (ce *ClusterError) Error() string
type ConfigClient ¶
type ConfigClient struct {
// contains filtered or unexported fields
}
type HttpClusterClient ¶
***********************************************************************
带集群功能的client,封装httpWeightClient The client with cluster functionality has encapsulate httpWeightClient
***********************************************************************
func GetClient ¶
func GetClient(scheme, host string) (*HttpClusterClient, error)
func New ¶
func New(scheme, host string, cfg *HttpClusterConfig) (*HttpClusterClient, error)
func (*HttpClusterClient) Len ¶
func (c *HttpClusterClient) Len() int
func (*HttpClusterClient) Less ¶
func (c *HttpClusterClient) Less(i, j int) bool
func (*HttpClusterClient) Pop ¶
func (c *HttpClusterClient) Pop() (client interface{})
func (*HttpClusterClient) Push ¶
func (c *HttpClusterClient) Push(client interface{})
func (*HttpClusterClient) Swap ¶
func (c *HttpClusterClient) Swap(i, j int)
type HttpClusterConfig ¶
type HttpClusterConfig struct { // A HeaderTimeoutPerRequest of zero means no timeout. HeaderTimeoutPerRequest time.Duration // retry times when request err Retry int Redirect bool // cert for request https Cert tls.Certificate }
func DefaultConfig ¶
func DefaultConfig() *HttpClusterConfig
Click to show internal directories.
Click to hide internal directories.