Skip to content

Commit

Permalink
feat(cql) add support for frames with custom payload
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Oct 1, 2018
1 parent aab0927 commit 2fe82cc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/cassandra/cql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ local OP_CODES = {
local FRAME_FLAGS = {
--COMPRESSION = 0x01,
TRACING = 0x02,
--CUSTOM_PAYLOAD = 0x04,
CUSTOM_PAYLOAD = 0x04,
WARNING = 0x08,
}

Expand Down Expand Up @@ -1376,14 +1376,18 @@ do
local op_code = header.op_code
local body = Buffer.new(header.version, bytes)

local tracing_id, warnings
if band(header.flags, FRAME_FLAGS.TRACING) ~= 0 then
tracing_id = body:read_uuid()
end
if band(header.flags, FRAME_FLAGS.CUSTOM_PAYLOAD) ~= 0 then
body:read_bytes_map() -- discard
end
if band(header.flags, FRAME_FLAGS.WARNING) ~= 0 then
warnings = body:read_string_list()
end

if op_code == OP_CODES.RESULT then
local tracing_id, warnings
if band(header.flags, FRAME_FLAGS.TRACING) ~= 0 then
tracing_id = body:read_uuid()
end
if band(header.flags, FRAME_FLAGS.WARNING) ~= 0 then
warnings = body:read_string_list()
end
local result_kind = body:read_int()
local parser = results_parsers[result_kind]
local res = parser(body)
Expand Down

0 comments on commit 2fe82cc

Please sign in to comment.