Skip to main content

Module channel_key

Module channel_key 

Expand description

The routing key one connection names on the capnp transport.

An app’s traffic is addressed by (app_id, cluster_id, record_id), but capnp’s joinChannel(channelId, identity) carries a single string, so the triple travels inside the channel id. This pair of functions is the only place the encoding is written down, so the two halves cannot drift apart.

§Shape

<cluster>[#app:<app_id>][#record:<record_id>]

A uuid contains no #. #record: is stripped first and takes everything after it, so a #-containing record id (a file path may have one) stays intact. Both suffixes are optional, so a missing #app: yields an empty app id rather than failing to parse — needed for the earlier two-field keys chrome traffic still rides.

Without the app id in this key, every packaged app would publish deltas cluster-scoped — one app’s changes delivered to every app in the room.

Functions§

format
Encode a route triple into one channel id.
parse
Decode a channel id into (app_id, cluster_id, record_id). Total: every string decodes, and one naming no marker is a bare cluster.