Documentation
¶
Overview ¶
Package whclient wraps a wsmux client session in a net.Listener interface. It attempts to reconnect to the proxy in case of a connection failure. It can be configured by setting the appropriate parameters in the Config object passed to whclient.New().
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRetryTimedOut is returned when Reconnect() time exceeds MaxElapsedTime. ErrRetryTimedOut = clientError{/* contains filtered or unexported fields */} // ErrBadToken is returned when a usable token can not be generated by the authorizer. ErrBadToken = clientError{/* contains filtered or unexported fields */} // ErrRetryFailed is returned when retry attempts fail. ErrRetryFailed = clientError{/* contains filtered or unexported fields */} // ErrClientReconnecting is returned when the connection is reconnecting. // This is a temporary error. ErrClientReconnecting = clientError{/* contains filtered or unexported fields */} // ErrClientClosed is returned from an Accept call when the client is closed. ErrClientClosed = clientError{/* contains filtered or unexported fields */} // ErrAuthorizerNotProvided is returned from New when an Authorizer is not provided. ErrAuthorizerNotProvided = clientError{/* contains filtered or unexported fields */} )
Functions ¶
Types ¶
type Authorizer ¶
Authorizer is a function which accepts a string `id` and returns a signed JWT (JSON Web Token). If an error occurs, the return values must be ("", ErrorGenerated).
type Config ¶
type Config struct {
// ID is the worker-id of the client. This field must match the "tid" claim of the
// JWT.
ID string
// ProxyAddr is the websocket address of the proxy to which the client should connect.
ProxyAddr string
// Logger is an optional field. This logger is passed to the session created by
// the GetListener method. This defaults to `&util.NilLogger{}`.
Logger util.Logger
Authorize Authorizer
// Retry contains the retry parameters to use in case of reconnects.
// The default values are specified in RetryConfig.
Retry RetryConfig
// TLSConfig to use for authentication
TLSConfig *tls.Config
}
Config is used for creating a new client.
type RetryConfig ¶
type RetryConfig struct {
// InitialDelay is the delay after which the first reconnect
// attempt takes place.
// Default = 500 * time.Millisecond
InitialDelay time.Duration
// MaxDelay is the maximum possible delay between two consecutive
// reconnect attempts.
// Default = 60 * time.Second
MaxDelay time.Duration
// MaxElapsedTime is the time after which reconnect will time out
// Default = 3 * time.Minute
MaxElapsedTime time.Duration
// Multplier is the rate at which the delay will increase
//Default = 1.5
Multiplier float64
// RandomizationFactor is the extent to which the delay values will be randomized
// Default = 0.5
RandomizationFactor float64
}
RetryConfig contains exponential backoff parameters for retrying connections
Click to show internal directories.
Click to hide internal directories.