Command line / channels
channels
tinystore channels publishes a message and listens to a channel from a
shell, with no SDK. A channel lives in the memory of the process that holds
the store, so both go through the server that holds the directory, or a
sidecar they start, and nothing is read beside it.
tinystore channels ./data publish chat-events '{"kind": "reload"}'
tinystore channels ./data subscribe chat-events --for 1mPublish a message
tinystore channels ./data publish chat-events '{"kind": "reload"}'
tinystore channels ./data publish chat-events '{"seen": 7}' --under room-42published to chat-events under room-42- A message is JSON.
-reads it from stdin. --under room-42sends it to a branch of the channel, its owners written as42/devices.- Every subscription listening now receives it, and no one else ever will: a message published while no one listens is gone, as the channels guide says.
- It is sent once. A message whose answer was lost may have been delivered, and sending it again would deliver it twice.
Listen to a channel
tinystore channels ./data subscribe chat-events --for 1mtinystore channels subscribe: listening on chat-events
{"kind":"reload"}
room-42 {"seen":7}- stderr says when it listens. A message published before that line is not received.
- Each message is a line on stdout, after its branch when it has one.
--jsongives{"under": […], "value": …}a line. --under room-42listens to one branch, and--recursiveto every branch below it too.--for 1mstops after a minute. Without it, it listens until stopped with Ctrl+C.- A subscription that falls too far behind loses messages, and stderr says how many.
See also
- channels: channels from a program, branches, and a transaction's messages at its commit.