Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultMaxBackoff = 30 * time.Second DefaultBackoffReset = 10 * time.Second DefaultPoolIdleSize = 10 DefaultPoolMaxSize = 100 )
View Source
const ( UNKNOWN = -1 CONNECTING = iota IDLE RUNNING )
Status of a Connection.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *Config // contains filtered or unexported fields }
Client connects to one or more Server using HTTP websockets. The Server can then send HTTP requests to execute.
type Config ¶
type Config struct { // Name is an optional client identifier. Only used in logs. Name string // ID is a required client identifier. All connections are pooled using the ID, // so make this unique if you don't want this client pooled with another. ID string // ClientIDs is simply saved with the connection data and available in stats. // It may be empty and is not directly used by this library. // It's for you to identify your clients with your own ID(s). ClientIDs []interface{} // Websocket URLs this client shall connect to. Targets []string // Minimum count of idle connections to maintain at all times. PoolIdleSize int // Maximum websocket connections to keep per target. PoolMaxSize int // SecretKey is passed as a header to the server to "authenticate". // The target servers must accept this value. SecretKey string // How often to reap dead connections from the target pools. // This also controls how often to re-try connections to the targets. CleanInterval time.Duration // How many seconds to backoff on every connection attempt. Backoff time.Duration // Maximum backoff length. MaxBackoff time.Duration // What to reset the backoff to when max is hit. // Set this to max to stay at max. BackoffReset time.Duration // If RRConfig is non-nil then the servers provided in Targets are // tried sequentially after they cannot be reached in RetryInterval. *RoundRobinConfig // If this is true, then the servers provided in Targets are tried // sequentially after they cannot be reached in RetryInterval. // Handler is an optional custom handler for all proxied requests. // Leaving this nil makes all requests use an empty http.Client. Handler func(http.ResponseWriter, *http.Request) // Logger allows routing logs from this package however you'd like. // If left nil, you will get no logs. Use DefaultLogger to print logs to stdout. mulch.Logger }
Config is the required data to initialize a client proxy connection.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection handle a single websocket (HTTP/TCP) connection to an Server.
func NewConnection ¶
func NewConnection(pool *Pool) *Connection
NewConnection creates a Connection object.
func (*Connection) Connect ¶
func (c *Connection) Connect(ctx context.Context) error
Connect to the remote server using an HTTP websocket.
func (*Connection) Status ¶
func (c *Connection) Status() int
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool of connections to a remote Server.
type PoolSize ¶
type PoolSize struct { Disconnects int Connecting int Idle int Running int Total int LastConn time.Time LastTry time.Time Active bool }
PoolSize represent the number of open connections per status.
type RoundRobinConfig ¶ added in v0.0.6
type RoundRobinConfig struct { // When RoundRobin is true, this configures how long a server is // retried unsuccessfully before trying the next server in Targets list. RetryInterval time.Duration // Callback is called when the tunnel changes. Callback func(ctx context.Context, socket string) }
RoundRobinConfig is the configuration specific to round robin target acquisition.
Click to show internal directories.
Click to hide internal directories.