diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-10 11:29:55 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-10 11:29:55 +0100 |
commit | c92f84d76e32100d6f5e1767a468cf3fe49a5db7 (patch) | |
tree | bc88432be97df1c816ebd7dfb97e89974291df94 /lualib | |
parent | 614b48d55f1a4084fd4ef9de95603ba4334e6837 (diff) | |
download | rspamd-c92f84d76e32100d6f5e1767a468cf3fe49a5db7.tar.gz rspamd-c92f84d76e32100d6f5e1767a468cf3fe49a5db7.zip |
[Feature] Store Clickhouse data outside of lua alloc
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_clickhouse.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lualib/lua_clickhouse.lua b/lualib/lua_clickhouse.lua index 4a57afd3f..2a75326d4 100644 --- a/lualib/lua_clickhouse.lua +++ b/lualib/lua_clickhouse.lua @@ -23,6 +23,7 @@ limitations under the License. local rspamd_logger = require "rspamd_logger" local rspamd_http = require "rspamd_http" local lua_util = require "lua_util" +local rspamd_text = require "rspamd_text" local exports = {} local N = 'clickhouse' @@ -81,9 +82,11 @@ local function row_to_tsv(row) end end - return table.concat(row, '\t') + return rspamd_text.fromtable(row, '\t') end +exports.row_to_tsv = row_to_tsv + -- Parses JSONEachRow reply from CH local function parse_clickhouse_response_json_eachrow(params, data) local ucl = require "ucl" @@ -373,9 +376,7 @@ exports.insert = function (upstream, settings, params, query, rows, http_params.user = settings.user http_params.password = settings.password http_params.method = 'POST' - http_params.body = {table.concat(fun.totable(fun.map(function(row) - return row_to_tsv(row) - end, rows)), '\n'), '\n'} + http_params.body = {rspamd_text.from_table(rows, '\n'), '\n'} http_params.log_obj = params.task or params.config if not http_params.url then |