Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Call(method string, values url.Values, body io.Reader, length int64) (reply io.ReadCloser, err error)
- func (c *Client) CallWithContext(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) MarkOffline()
- type NetworkError
Constants ¶
const DefaultRESTTimeout = 1 * time.Minute
DefaultRESTTimeout - default RPC timeout is one minute.
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 // 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 // contains filtered or unexported fields }
Client - http based RPC client.
func NewClient ¶
func NewClient(url *url.URL, newCustomTransport func() *http.Transport, newAuthToken func(aud string) string) *Client
NewClient - returns new REST client.
func (*Client) Call ¶
func (c *Client) Call(method string, values url.Values, body io.Reader, length int64) (reply io.ReadCloser, err error)
Call - make a REST call.
func (*Client) CallWithContext ¶
func (c *Client) CallWithContext(ctx context.Context, method string, values url.Values, body io.Reader, length int64) (reply io.ReadCloser, err error)
CallWithContext - 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 ¶
func (c *Client) MarkOffline()
MarkOffline - will mark a client as being offline and spawns a goroutine that will attempt to reconnect if HealthCheckFn is set.
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.