top

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.

Imports 6 package(s) ΒΆ

  1. github.com/op/go-logging
  2. github.com/gorilla/websocket
  3. github.com/julienschmidt/httprouter
  4. gopkg.in/mgo.v2/bson
  5. github.com/gtfierro/giles/archiver
  6. github.com/bitly/go-simplejson