diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-29 11:37:13 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-29 11:37:13 +0000 |
commit | 2c868bb0a46ae17d6017f889b6aae6f136d9fb1e (patch) | |
tree | ed947badfe3a2a07f32697a24e594b7acfd130db | |
parent | f9ca8132707ffd68f5dc7bac2edff081b6d74b9b (diff) | |
download | rspamd-2c868bb0a46ae17d6017f889b6aae6f136d9fb1e.tar.gz rspamd-2c868bb0a46ae17d6017f889b6aae6f136d9fb1e.zip |
[Minor] Elastic: Switch off coroutines as they are unstable
-rw-r--r-- | src/plugins/lua/elastic.lua | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua index a223756e4..935768497 100644 --- a/src/plugins/lua/elastic.lua +++ b/src/plugins/lua/elastic.lua @@ -79,12 +79,30 @@ local function elastic_send_data(task) local push_url = connect_prefix .. ip_addr .. '/'..es_index..'/_bulk' local bulk_json = table.concat(tbl, "\n") - local err, response = rspamd_http.request({ + + local function http_callback(err, code, _, _) + if err then + rspamd_logger.infox(task, "cannot push data to elastic backend (%s): %s; failed attempts: %s/%s", + push_url, err, failed_sends, settings.max_fail) + else + if code ~= 200 then + rspamd_logger.infox(task, + "cannot push data to elastic backend (%s): wrong http code %s (%s); failed attempts: %s/%s", + push_url, err, code, failed_sends, settings.max_fail) + else + lua_util.debugm(N, task, "successfully sent %s (%s bytes) rows to ES", + nrows, #bulk_json) + end + end + end + + rspamd_http.request({ url = push_url, headers = { ['Content-Type'] = 'application/x-ndjson', }, body = bulk_json, + callback = http_callback, task = task, method = 'post', gzip = settings.use_gzip, @@ -93,24 +111,6 @@ local function elastic_send_data(task) password = settings.password, timeout = settings.timeout, }) - - if err then - rspamd_logger.infox(task, "cannot push data to elastic backend (%s): %s; failed attempts: %s/%s", - push_url, err, failed_sends, settings.max_fail) - else - if response.code ~= 200 then - rspamd_logger.infox(task, - "cannot push data to elastic backend (%s): wrong http code %s (%s); failed attempts: %s/%s", - push_url, err, response.code, failed_sends, settings.max_fail) - else - lua_util.debugm(N, task, "successfully sent %s (%s bytes) rows to ES", - nrows, #bulk_json) - - return true - end - end - - return false end local function get_general_metadata(task) |