commit 087e331: [Minor] Clickhouse: Add exceptions logic
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu May 23 14:42:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-05-23 15:37:15 +0100
URL: https://github.com/rspamd/rspamd/commit/087e3318348d368c2b0639a44abff418f91ef94b
[Minor] Clickhouse: Add exceptions logic
---
src/plugins/lua/clickhouse.lua | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index ccaee3042..599164006 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -76,6 +76,7 @@ local settings = {
no_ssl_verify = false,
custom_rules = {},
enable_digest = false,
+ exceptions = nil,
retention = {
enable = false,
method = 'detach',
@@ -380,12 +381,27 @@ local function clickhouse_send_data(task, ev_base)
end
local function clickhouse_collect(task)
- if task:has_flag('skip') then return end
- if not settings.allow_local and rspamd_lua_utils.is_rspamc_or_controller(task) then return end
+ if task:has_flag('skip') then
+ return
+ end
+
+ if not settings.allow_local and rspamd_lua_utils.is_rspamc_or_controller(task) then
+ return
+ end
for _,sym in ipairs(settings.stop_symbols) do
if task:has_symbol(sym) then
- lua_util.debugm(N, task, 'skip collection as symbol %s has fired', sym)
+ rspamd_logger.infox(task, 'skip Clickhouse storage for message: symbol %s has fired', sym)
+ return
+ end
+ end
+
+ if settings.exceptions then
+ local excepted,trace = settings.exceptions:process(task)
+ if excepted then
+ rspamd_logger.infox(task, 'skipped Clickhouse storage for message: excepted (%s)',
+ trace)
+ -- Excepted
return
end
end
@@ -1069,6 +1085,13 @@ if opts then
return
end
+ if settings.exceptions then
+ local maps_expressions = require "lua_maps_expressions"
+
+ settings.exceptions = maps_expressions.create(rspamd_config,
+ settings.exceptions, N)
+ end
+
rspamd_config:register_symbol({
name = 'CLICKHOUSE_COLLECT',
type = 'idempotent',
More information about the Commits
mailing list