Documentation ¶
Index ¶
- type Config
- type Connection
- type ConnectionStatus
- type Message
- type Pool
- func (p *Pool) Clean()
- func (p *Pool) GetIdleConnection(ctx context.Context) (conn *Connection)
- func (p *Pool) IsEmpty() bool
- func (p *Pool) Offer(connection *Connection)
- func (p *Pool) RegisterConnection(ws *websocket.Conn)
- func (p *Pool) SetSize(size int)
- func (p *Pool) Shutdown()
- func (p *Pool) Size() (ps *PoolSize)
- type PoolID
- type PoolSize
- type Pools
- 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 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 ¶
Pool handles all connections from the peer.
func (*Pool) GetIdleConnection ¶ added in v0.14.0
func (p *Pool) GetIdleConnection(ctx context.Context) (conn *Connection)
func (*Pool) Offer ¶
func (p *Pool) Offer(connection *Connection)
func (*Pool) RegisterConnection ¶ added in v0.14.0
RegisterConnection creates a new Connection and adds it to the pool
type PoolID ¶
type PoolID string
PoolID represents the identifier of the connected WebSocket client.
type Pools ¶ added in v0.14.0
func (*Pools) MoreThenOne ¶ added in v0.14.0
func (*Pools) RegisterConnection ¶ added in v0.14.0
type Server ¶
type Server struct {
// 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