Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Call(ctx context.Context, method string, values url.Values, body io.Reader, ...) (reply io.ReadCloser, err error)
- func (c *Client) Close()
- func (c *Client) IsOnline() bool
- func (c *Client) LastConn() time.Time
- func (c *Client) LastError() error
- func (c *Client) MarkOffline(err error) bool
- type NetworkError
- type RPCStats
Constants ¶
const DefaultTimeout = 10 * time.Second
DefaultTimeout - default REST timeout is 10 seconds.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 // HealthCheckRetryUnit will be used to calculate the exponential // backoff when trying to reconnect to an offline node HealthCheckReconnectUnit 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 // Avoid metrics update if set to true NoMetrics bool // TraceOutput will print debug information on non-200 calls if set. TraceOutput io.Writer // Debug trace output sync.RWMutex // mutex for lastErr // 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.