Documentation ¶
Index ¶
- Constants
- type CommandResult
- type Controller
- type DisconnectQueue
- type Hub
- type Message
- type Node
- func (n *Node) Authenticate(s *Session, path string, headers *map[string]string) error
- func (n *Node) Broadcast(msg *StreamMessage)
- func (n *Node) Disconnect(s *Session)
- func (n *Node) DisconnectNow(s *Session) error
- func (n *Node) HandleCommand(s *Session, raw []byte)
- func (n *Node) HandlePubsub(raw []byte)
- func (n *Node) Perform(s *Session, msg *Message)
- func (n *Node) Shutdown()
- func (n *Node) Subscribe(s *Session, msg *Message)
- func (n *Node) Unsubscribe(s *Session, msg *Message)
- type Reply
- type Session
- type StreamMessage
- type SubscriptionInfo
Constants ¶
const ( // CloseNormalClosure indicates normal closure CloseNormalClosure = websocket.CloseNormalClosure // CloseInternalServerErr indicates closure because of internal error CloseInternalServerErr = websocket.CloseInternalServerErr // CloseAbnormalClosure indicates ubnormal close CloseAbnormalClosure = websocket.CloseAbnormalClosure // CloseGoingAway indicates ubnormal close CloseGoingAway = websocket.CloseGoingAway )
const (
// PING stores the "ping" message identifier
PING = "ping"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandResult ¶
type CommandResult struct { Streams []string StopAllStreams bool Transmissions []string Disconnect bool }
CommandResult is a result of performing controller action, which contains informations about streams to subscribe, messages to sent
type Controller ¶
type Controller interface { Shutdown() error Authenticate(sid string, path string, headers *map[string]string) (string, []string, error) Subscribe(sid string, id string, channel string) (*CommandResult, error) Unsubscribe(sid string, id string, channel string) (*CommandResult, error) Perform(sid string, id string, channel string, data string) (*CommandResult, error) Disconnect(sid string, id string, subscriptions []string, path string, headers *map[string]string) error }
Controller is an interface describing business-logic handler (e.g. RPC)
type DisconnectQueue ¶
type DisconnectQueue struct {
// contains filtered or unexported fields
}
DisconnectQueue is a rate-limited executor
func NewDisconnectQueue ¶
func NewDisconnectQueue(node *Node, rate int) *DisconnectQueue
NewDisconnectQueue builds new queue with a specified rate (max calls per second)
func (*DisconnectQueue) Enqueue ¶
func (d *DisconnectQueue) Enqueue(s *Session)
Enqueue adds session to the disconnect queue
func (*DisconnectQueue) Shutdown ¶
func (d *DisconnectQueue) Shutdown() error
Shutdown stops throttling and makes requests one by one
func (*DisconnectQueue) Size ¶
func (d *DisconnectQueue) Size() int
Size returns the number of enqueued tasks
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub stores all the sessions and the corresponding subscriptions info
func (*Hub) StreamsSize ¶
StreamsSize returns a number of uniq streams
type Message ¶
type Message struct { Command string `json:"command"` Identifier string `json:"identifier"` Data string `json:"data"` }
Message represents incoming client message
type Node ¶
type Node struct { Config *config.Config Metrics *metrics.Metrics // contains filtered or unexported fields }
Node represents the whole application
func (*Node) Authenticate ¶
Authenticate calls controller to perform authentication. If authentication is successful, session is registered with a hub.
func (*Node) Disconnect ¶
Disconnect adds session to disconnector queue and unregister session from hub
func (*Node) DisconnectNow ¶
DisconnectNow execute disconnect on controller
func (*Node) HandleCommand ¶
HandleCommand parses incoming message from client and execute the command (if recognized)
func (*Node) HandlePubsub ¶
HandlePubsub parses incoming pubsub message and broadcast it
func (*Node) Unsubscribe ¶
Unsubscribe unsubscribes session from a channel
type Reply ¶
type Reply struct { Type string `json:"type,omitempty"` Identifier string `json:"identifier"` Message interface{} `json:"message"` }
Reply represents outgoing client message
type Session ¶
type Session struct { UID string Identifiers string Log *log.Entry // contains filtered or unexported fields }
Session represents active client
func NewSession ¶
NewSession build a new Session struct from ws connetion and http request
func (*Session) Disconnect ¶
Disconnect enqueues RPC disconnect request and closes the connection
func (*Session) ReadMessages ¶
func (s *Session) ReadMessages()
ReadMessages reads messages from ws connection and send them to node
func (*Session) SendMessages ¶
SendMessages waits for incoming messages and send them to the client connection
type StreamMessage ¶
StreamMessage represents a message to be sent to stream
type SubscriptionInfo ¶
type SubscriptionInfo struct {
// contains filtered or unexported fields
}
SubscriptionInfo contains information about session-channel(-stream) subscription