Documentation ¶
Index ¶
Constants ¶
const DefaultTimeout = 10 * time.Second
DefaultTimeout - default REST timeout is 10 seconds.
Variables ¶
This section is empty.
Functions ¶
func GetNetworkErrsCounter ¶
func GetNetworkErrsCounter() uint64
GetNetworkErrsCounter returns the number of failed RPC requests
func ResetNetworkErrsCounter ¶
func ResetNetworkErrsCounter()
ResetNetworkErrsCounter resets the number of failed RPC requests
Types ¶
type Client ¶
type Client struct { // HealthCheckFn is the function set to test for health. // If not set the client will not keep track of health. // Calling this returns true or false if the target // is online or offline. HealthCheckFn func() bool // HealthCheckInterval will be the duration between re-connection attempts // when a call has failed with a network error. HealthCheckInterval time.Duration // HealthCheckTimeout determines timeout for each call. HealthCheckTimeout time.Duration // MaxErrResponseSize is the maximum expected response size. // Should only be modified before any calls are made. MaxErrResponseSize int64 // ExpectTimeouts indicates if context timeouts are expected. // This will not mark the client offline in these cases. ExpectTimeouts bool // Avoid metrics update if set to true NoMetrics bool // contains filtered or unexported fields }
Client - http based RPC client.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, method string, values url.Values, body io.Reader, length int64) (reply io.ReadCloser, err error)
Call - make a REST call with context.
func (*Client) Close ¶
func (c *Client) Close()
Close closes all idle connections of the underlying http client
func (*Client) MarkOffline ¶
MarkOffline - will mark a client as being offline and spawns a goroutine that will attempt to reconnect if HealthCheckFn is set. returns true if the node changed state from online to offline
type NetworkError ¶
type NetworkError struct {
Err error
}
NetworkError - error type in case of errors related to http/transport for ex. connection refused, connection reset, dns resolution failure etc. All errors returned by storage-rest-server (ex errFileNotFound, errDiskNotFound) are not considered to be network errors.
func (*NetworkError) Error ¶
func (n *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (n *NetworkError) Unwrap() error
Unwrap returns the error wrapped in NetworkError.