habitat.archive: Storing messages in CouchDB

ArchiveSink stores messages in a CouchDB datastore.

class habitat.archive.ArchiveSink(server)[source]

The ArchiveSink is responsible for storing data in the Couch database. It will create and modify documents as required to store incoming messages, listener information and parsed telemetry.

setup()[source]

Add all message types to those we should receive.

message(message)[source]

Handle an incoming message, storing it in the datastore.

There are four varients of incoming message:

  • RECEIVED_TELEM (raw telemetry strings):

    These are stored as payload_telemetry documents, with the base64 encoded raw data in _raw inside data, information on who received it in receivers and the document ID set to the sha256 sum of the base64 data.

  • TELEM (parsed telemetry data):

    These are stored as per RECEIVED_TELEM, with the parsed data placed in the data dictionary along with the raw data in _raw and additionally a _protocol field specifying which parser was used to extract the data.

  • LISTENER_TELEM (telemetry concerning listeners):

    Stored in listener_telemetry documents, typically specifying a position and corresponding time and the listener’s callsign.

  • LISTENER_INFO (general information on a listener):

    Stored in listener_info documents, containing any metadata the listener wishes to submit but generally consisting of a name, location, radio, antenna or other information along with their callsign.

When a new RECEIVED_TELEM or TELEM message comes in, the database is checked for an existing document for this message. If none is found, a new one is created: in the case of RECEIVED_TELEM, the new one contains the received data in _raw in data, while for TELEM messages all the parsed data is put in data. If a document is found, any new data from the current message is written over anything in the database (though no data will be deleted without anything to replace it).

When new LISTENER_TELEM messages come in, they are directly created as a new document.

When new LISTENER_INFO messages are received, a check is done on this callsign’s latest document and a new one is only created if the new message is different from the current data in the database.

Previous topic

habitat python reference

Next topic

habitat.http: message insertion by HTTP POST

This Page