Created
June 1, 2015 01:57
-
-
Save matschaffer/bd54aa8d0b91ca4c4c0c to your computer and use it in GitHub Desktop.
heka decoder harness - expects "payload" and "config.json" to be in pwd
This file contains 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
return { | |
send = function(ns, message) | |
print("alert - " .. ns .. ": " .. message) | |
end | |
} |
This file contains 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
#!/usr/bin/env lua | |
local sandbox_file = arg[1] | |
local sandbox_file_path = string.gsub(sandbox_file, "(.*/)(.*)", "%1") | |
local sandbox_module = string.gsub(sandbox_file, "(.*/)(.*)%.(.*)", "%2") | |
package.path = sandbox_file_path .. "?.lua;" .. package.path | |
local cj = require "cjson" | |
local config_file = io.open("config.json", "rb") | |
local config = cj.decode(config_file:read("*all")) | |
config_file:close() | |
function read_config (key) | |
return config[key] | |
end | |
local payload_file = io.open("payload", "rb") | |
local payload = payload_file:read("*all") | |
payload_file:close() | |
function read_message (key) | |
local message = { | |
Timestamp = 1420070400000000000, | |
Payload = payload | |
} | |
return message[key] | |
end | |
require(sandbox_module) | |
process_message() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment