thbkrkr
4/16/2017 - 7:21 PM

blink stick on pingpong kafka message

blink stick on pingpong kafka message

#!/bin/bash -eu
#
# Toggle 2 LED on each kafka message.
# @dep jq, oq (https://github.com/thbkrkr/qli/releases/download/0.2.1/oq), blinkstick (pip install blinkstick)
#
get() { jq -r .message <<< $1 2>/dev/null; }
blink() { blinkstick --index $1 --pulse $2 --brightness 40 --duration 70; } 

while read msg; do

	msg=$(get $msg)
	echo "$msg"
	case "$msg" in
		ping) 	blink 1 cyan & ;;
		pong) 	blink 6 green & ;;
	esac

done < <(oq -t thbkrkr.pingpong)