Documentation
¶
Index ¶
- Constants
- Variables
- type Connections
- func (cs *Connections) Append(attributes map[string]string, conn *websocket.Conn) (*websocketactions.Connection, int)
- func (cs *Connections) CloseConnections(wa websocketactions.IWebsocketActions, attributes map[string]string)
- func (cs *Connections) Get(attributes map[string]string) []*websocketactions.Connection
- func (cs *Connections) Len() int
- func (cs *Connections) Remove(attributes map[string]string)
- func (cs *Connections) RemoveID(id int)
- type Gateway
- func (nh *Gateway) AcceptWebsocketConnection(w http.ResponseWriter, r *http.Request) (*websocket.Conn, map[string]string, error)
- func (nh *Gateway) CleanupIncomingConnection(id int)
- func (nh *Gateway) CleanupOutgoingConnection(notificationAtt map[string]string)
- func (nh *Gateway) RestAPINotificationHandler(w http.ResponseWriter, r *http.Request)
- func (nh *Gateway) SendNotification(route map[string]string, notification []byte, sendSynchronicity bool) ([]int, error)
- func (ns *Gateway) SetupAndServe()
- func (nh *Gateway) UnmarshalMessage(message []byte) (*Notification, error)
- func (nh *Gateway) WebsocketNotificationHandler(w http.ResponseWriter, r *http.Request)
- func (nh *Gateway) WebsocketReceiveNotification(connObj *websocketactions.Connection) error
- type Notification
- type RegexpHandler
Constants ¶
const ( ConfigEnvironmentVariable = "CONFIG" GatewayWebsocketPortEnvironmentVariable = "WEBSOCKET_PORT" GatewayRestApiPortEnvironmentVariable = "HTTP_PORT" ParentGatewayHostEnvironmentVariable = "PARENT_URL" ReleaseBuildTagEnvironmentVariable = "RELEASE" )
Variables ¶
var ( PortRestAPI = "8002" PortWebsocket = "8001" )
Functions ¶
This section is empty.
Types ¶
type Connections ¶
type Connections struct {
// contains filtered or unexported fields
}
Connections manages the open websocket connections. It acts as a routing table that routes requests to matching connections by the attributes provided in requests
func NewConnectionsObj ¶
func NewConnectionsObj() *Connections
NewConnectionsObj creates a new Connections object
func (*Connections) Append ¶
func (cs *Connections) Append(attributes map[string]string, conn *websocket.Conn) (*websocketactions.Connection, int)
Append appends a given connection with provided attributes to the current connections
func (*Connections) CloseConnections ¶
func (cs *Connections) CloseConnections(wa websocketactions.IWebsocketActions, attributes map[string]string)
CloseConnections closes all connections that have a set of provided attributes
func (*Connections) Get ¶
func (cs *Connections) Get(attributes map[string]string) []*websocketactions.Connection
Get retrieves a connection with given attributes from the routing table
func (*Connections) Len ¶
func (cs *Connections) Len() int
Len returns the number of the currently managed connections
func (*Connections) Remove ¶
func (cs *Connections) Remove(attributes map[string]string)
Remove removes a connection with given attributes from the routing table
func (*Connections) RemoveID ¶
func (cs *Connections) RemoveID(id int)
RemoveID removes a connection with a given ID from the routing table
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the main Gateway service object. It acts as a facade that manages incoming and outgoing connections, routes messages to recipients etc.
func (*Gateway) AcceptWebsocketConnection ¶
func (nh *Gateway) AcceptWebsocketConnection(w http.ResponseWriter, r *http.Request) (*websocket.Conn, map[string]string, error)
AcceptWebsocketConnection accepts an incoming websocket connection
func (*Gateway) CleanupIncomingConnection ¶
CleanupIncomingConnection cleans up an incoming connection with a given ID
func (*Gateway) CleanupOutgoingConnection ¶
CleanupOutgoingConnection cleans up an incoming connection with given notification attributes
func (*Gateway) RestAPINotificationHandler ¶
func (nh *Gateway) RestAPINotificationHandler(w http.ResponseWriter, r *http.Request)
RestAPINotificationHandler handles the notifications received over the REST API
func (*Gateway) SendNotification ¶
func (nh *Gateway) SendNotification(route map[string]string, notification []byte, sendSynchronicity bool) ([]int, error)
SendNotification sends a notification to its intended recipient
func (*Gateway) SetupAndServe ¶
func (ns *Gateway) SetupAndServe()
SetupAndServe configures the HTTP servers and makes them serve incoming requests
func (*Gateway) UnmarshalMessage ¶
func (nh *Gateway) UnmarshalMessage(message []byte) (*Notification, error)
UnmarshalMessage attempts to unmarshal a given message into either a JSON or BSON format
func (*Gateway) WebsocketNotificationHandler ¶
func (nh *Gateway) WebsocketNotificationHandler(w http.ResponseWriter, r *http.Request)
WebsocketNotificationHandler establishes a websocket connection and handles incoming notifications
func (*Gateway) WebsocketReceiveNotification ¶
func (nh *Gateway) WebsocketReceiveNotification(connObj *websocketactions.Connection) error
WebsocketReceiveNotification maintains the websocket connection and receives notifications sent over it
type Notification ¶
type Notification notifier.Notification
type RegexpHandler ¶
type RegexpHandler struct {
// contains filtered or unexported fields
}
RegexpHandler describes a Handler that handles requests that have a URL path that matches an associated regular expression
func (*RegexpHandler) HandleFunc ¶
func (h *RegexpHandler) HandleFunc(pattern *regexp.Regexp, handler func(http.ResponseWriter, *http.Request))
HandleFunc registers a given handler function to the provided route pattern
func (*RegexpHandler) Handler ¶
func (h *RegexpHandler) Handler(pattern *regexp.Regexp, handler http.Handler)
Handler registers a given handler to the provided route pattern
func (*RegexpHandler) ServeHTTP ¶
func (h *RegexpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves the handler