MQTT for subscription/notify

The Internet-of-Things protocol MQTT offers subscription channels, and notifies of updates. This may be used to instantly receive the latest information, including for backup services that help other carbon administration nodes.

HTTP is the primary place for retrieving data. It has a fixed name that accesses the latest data, including references to older files. The fixed latest-data name may for instance be latest.json.asc and it may be a reference to a fixed-named file for that generation, such as 123.json.asc.

The MQTT information represents the dynamicity of this reference, by default topic /carbon-budget/$DOMAIN where $DOMAIN is the value in the "domain" word of the "self" party information. The value in this name is the full HTTP URI of the latest static file, in the example above that would be 123.json.asc.

When a new version of the Carbon Budget OpenData is published, it will be stored at a higher sequence number, for instance 124.json.asc and that will be the content of the fixed latest-data HTTP name (latest.json.asc in the example given) and it will be stored in the MQTT topic /carbon-budget/$DOMAIN given before.

MQTT information should retain the latest published version. It does not need to keep historic versions, because the latest will link back to the URLs of all previous versions. Clients updating can follow these links until they hit a point that they already hold. This allows research of both up-to-date and historic traces of the data.

Note that the format /carbon-budget/$DOMAIN can be used to place any number of domains on one server. This is deliberate, because it allows MQTT brokers to pull in information from other MQTT brokers, basically serving as a bridge or as a backup facility for those externally managed $DOMAIN nodes.

MQTT should be used without authentication. It may use a TLS-secured protocol or plaintext, as configured in the "mqtt" URL in the "self" party in the carbon budgetting files shared over HTTP.

An example subscription with a Mosquitto client look like this:

shell$ mosquitto_sub -h ::1 -p 1883 -t '/carbon-budget/example.com'
https://example.com/carbon-budget/example.com/5.json.asc
https://example.com/carbon-budget/example.com/6.json.asc
https://example.com/carbon-budget/example.com/7.json.asc

The point is that new data pours in immediately, making it no longer necessary to regularly download the data. When disconnected and reconnected, the client will start by repeating the last value:

shell$ mosquitto_sub -h ::1 -p 1883 -t '/carbon-budget/example.com'
https://example.com/carbon-budget/example.com/7.json.asc