Documentation ¶
Index ¶
- type Config
- type Connection
- type ConnectionRequest
- type ConnectionStatus
- type Message
- type Pool
- type PoolID
- type PoolSize
- type Server
- func (s *Server) GetServerID(r *http.Request) (serverID string, err error)
- func (s *Server) Register(w http.ResponseWriter, r *http.Request)
- func (s *Server) Request(w http.ResponseWriter, r *http.Request)
- func (s *Server) Shutdown()
- func (s *Server) Start()
- func (s *Server) Ws(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection manages a single websocket connection from the peer. wsp supports multiple connections from a single peer at the same time.
func NewConnection ¶
func NewConnection(pool *Pool, ws *websocket.Conn) *Connection
NewConnection returns a new Connection.
func (*Connection) Release ¶
func (c *Connection) Release()
Release notifies that this connection is ready to use again
func (*Connection) Take ¶
func (c *Connection) Take() bool
Take notifies that this connection is going to be used
func (*Connection) WritePump ¶ added in v0.13.1
func (c *Connection) WritePump()
type ConnectionRequest ¶
type ConnectionRequest struct {
// contains filtered or unexported fields
}
ConnectionRequest is used to request a proxy connection from the dispatcher
func NewConnectionRequest ¶
func NewConnectionRequest(timeout time.Duration, serverId PoolID) (cr *ConnectionRequest)
NewConnectionRequest creates a new connection request
type ConnectionStatus ¶
type ConnectionStatus int
ConnectionStatus is an enumeration type which represents the status of WebSocket connection.
const ( // Idle state means it is opened but not working now. // The default value for Connection is Idle, so it is ok to use zero-value(int: 0) for Idle status. Idle ConnectionStatus = iota Busy Closed )
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool handles all connections from the peer.
func (*Pool) Clean ¶
func (p *Pool) Clean()
Clean removes dead connection from the pool Look for dead connection in the pool This MUST be surrounded by pool.lock.Lock()
func (*Pool) Offer ¶
func (p *Pool) Offer(connection *Connection)
Offer offers an idle connection to the server.
type PoolID ¶
type PoolID string
PoolID represents the identifier of the connected WebSocket client.
type Server ¶
type Server struct { Config *Config // contains filtered or unexported fields }
Server is a Reverse HTTP Proxy over WebSocket This is the Server part, Clients will offer websocket connections, those will be pooled to transfer HTTP Request and response