calog/examples/scripts/multifile/consumer.lua

16 lines
736 B
Lua

-- consumer.lua -- the other half of a MULTI-FILE calog run (see producer.js).
--
-- Run BOTH files together:
-- bin/calog examples/scripts/multifile/producer.js examples/scripts/multifile/consumer.lua
--
-- Subscribes to the shared pubsub bus; when the producer (a separate .js file) signals,
-- reads the values it left in the shared kv store, prints them, and ends the whole run.
-- One calogExit() from any file tears the whole (multi-file) process down.
psSubscribe("ready", function()
local greeting = kvGet("greeting")
local from = kvGet("from")
calogPrint("consumer.lua: got the signal ->", greeting, "from", from)
calogExit(0)
end)
calogPrint("consumer.lua: subscribed to 'ready', waiting for the producer")