Documentation ¶
Overview ¶
Package wshandler implements a WebSockets interface to the Archiver API at http://godoc.org/github.com/gtfierro/giles/archiver
Overview ¶
The WebSockets interface is designed as a less-hacky version of the HTTP republish mechanism, offering slightly augmented semantics for the connection. This interface is only for streaming data described by queries such as "select data before now where UUID = 123" or "select distinct Metadata/HVACZone". In the first case, we have a data query, so every time a new point is published to a stream matching the WHERE clause, a JSON message is sent over the WebSocket to the concerned client. In the second case, we have a metadata query, so every time the results of that query change, a JSON message is sent. These JSON messages have the same schema as the usual sMAP messages.
To initialize a connection, the client uses its usual WebSocket setup/upgrade to the desired URL (e.g. '/ws/api/query'), and then sends the query along the WebSocket to the server. Whenever the server receives a message from a client, that message will be evaluated as a query and will change the nature of the republish subscription. If the query is invalid, the server will send back an error message and maintain the current subscription.
Index ¶
- func Handle(a *archiver.Archiver, port int)
- func QueryRepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ...)
- func RepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ...)
- func UUIDRepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ...)
- func WsAddReadingHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ...)
- func WsQueryHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ...)
- func WsTagsHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ...)
- type WSSubscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QueryRepublishHandler ¶
func QueryRepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)
func RepublishHandler ¶
func RepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)
func UUIDRepublishHandler ¶
func UUIDRepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)
func WsAddReadingHandler ¶
func WsAddReadingHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)
func WsQueryHandler ¶
func WsQueryHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)
func WsTagsHandler ¶
func WsTagsHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)
Types ¶
type WSSubscriber ¶
type WSSubscriber struct {
// contains filtered or unexported fields
}
func NewWSSubscriber ¶
func NewWSSubscriber(ws *websocket.Conn, rw http.ResponseWriter) *WSSubscriber
func (*WSSubscriber) GetNotify ¶
func (wss *WSSubscriber) GetNotify() <-chan bool
func (*WSSubscriber) Send ¶
func (wss *WSSubscriber) Send(msg interface{})
func (*WSSubscriber) SendError ¶
func (wss *WSSubscriber) SendError(e error)