Created
March 31, 2015 15:40
-
-
Save aaronfeng/5ae1db42c419f4c5ad4a to your computer and use it in GitHub Desktop.
heka foo decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cjson = require("cjson") | |
function process_message() | |
local payload_str = read_message("Payload") | |
local ok, payload = pcall(cjson.decode, payload_str) | |
if not ok then | |
return -1 | |
end | |
payload["bar"] = read_message("Logger") | |
local ok, payload_with_bar = pcall(cjson.encode, payload) | |
if not ok then | |
return -1 | |
end | |
write_message("Payload", payload_with_bar) | |
return 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment