Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
Last active April 13, 2020 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leandromoreira/d34e256025709030d3ac773b578be0b3 to your computer and use it in GitHub Desktop.
Save leandromoreira/d34e256025709030d3ac773b578be0b3 to your computer and use it in GitHub Desktop.
--- fetch ---
local resp, err = redis_client:smembers("coding_units")
local raw_coding_units = {}
for _, coding_unit_key in ipairs(resp) do
local resp, err = redis_client:get(coding_unit_key) -- it'd be nice to keep the id for logging reasons
table.insert(raw_coding_units, resp)
end
--- fetch ---
--- parse ---
local coding_units = {}
for _, raw_coding_unit in ipairs(raw_coding_units) do
local parts = mysplit(raw_coding_unit, "||")
local cu = {}
cu['phase'] = parts[1]
cu['code'] = parts[2]
table.insert(coding_units, cu)
end
--- parse ---
--- execute ---
for _, coding_unit in ipairs(coding_units) do
if coding_unit['phase'] == 'current_phase' then
--- error checking omited ---
local function_code, err = loadstring(coding_unit['code'])
local status, ret = xpcall(function_code, err_handler)
end
end
--- execute ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment