Circular Buffer Delta Module

1. Variables

  • grammar - LPEG grammar to parse cbufd output

2. Usage

local cbufd = require "lpeg.cbufd".grammar

function process_message()
    local payload = read_message("Payload")
    local t = cbufd:match(payload)
    if not t then
        return -1, "invalid cbufd string"
    end
    -- use t
    return 0
end

3. Sample Input/Output

3.1. Circular Buffer Delta Input

{"time":1379574900,"rows":1440,"columns":2,"seconds_per_row":60,"column_info":[{"name":"Requests","unit":"count","aggregation":"sum"},{"name":"Total_Size","unit":"KiB","aggregation":"sum"}]}
1379660520      12075   159901
1379660280      11837   154880

3.2. Lua Table Output

{
header='{"time":1379574900,"rows":1440,"columns":2,"seconds_per_row":60,"column_info":[{"name":"Requests","unit":"count","aggregation":"sum"},{"name":"Total_Size","unit":"KiB","aggregation":"sum"}]}',
{12075, 159901, time = 1379660520000000000},
{11837, 154880, time = 1379660280000000000}
}

source code: cbufd.lua

results matching ""

    No results matching ""