First draft of the pub/sub notifier

This commit is contained in:
kexkey
2019-05-17 18:29:06 -04:00
committed by kexkey
parent 2c3b28bc84
commit ed71a2ed8f
13 changed files with 231 additions and 19 deletions

View File

@@ -0,0 +1,38 @@
#!/bin/sh
. ./trace.sh
. ./web.sh
. ./response.sh
main() {
trace "Entering main()..."
local msg
local cmd
local response
local response_topic
while read msg; do
trace "[main] msg=${msg}"
cmd=$(echo ${msg} | jq ".cmd" | tr -d '"')
trace "[main] cmd=${cmd}"
response_topic=$(echo ${msg} | jq '."response-topic"' | tr -d '"')
trace "[main] response_topic=${response_topic}"
case "${cmd}" in
web)
response=$(web "${msg}")
publish_response "${response}" "${response_topic}" ${?}
trace "[main] PR"
;;
esac
trace "[main] case finished"
done
}
export TRACING=1
main
exit $?