diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-12 14:50:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 14:50:57 +0000 |
commit | 23459dc3e306b497ae1450dfd07abdca1ac7f7be (patch) | |
tree | dbaf94e951038b4a3d5032686ae3607575dcb285 | |
parent | a639c5fae0943ce758e9dc36cb57a2e81849c933 (diff) | |
parent | 4da87a5cdaa931a7e0e716b8095594d3cdae0287 (diff) | |
download | rspamd-23459dc3e306b497ae1450dfd07abdca1ac7f7be.tar.gz rspamd-23459dc3e306b497ae1450dfd07abdca1ac7f7be.zip |
Merge pull request #4739 from fatalbanana/bayes_redis
[Minor] Have bayes use global redis settings
-rw-r--r-- | lualib/lua_bayes_redis.lua | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lualib/lua_bayes_redis.lua b/lualib/lua_bayes_redis.lua index d84d67498..96a505518 100644 --- a/lualib/lua_bayes_redis.lua +++ b/lualib/lua_bayes_redis.lua @@ -66,20 +66,33 @@ end exports.lua_bayes_init_statfile = function(classifier_ucl, statfile_ucl, symbol, is_spam, ev_base, stat_periodic_cb) local redis_params - if classifier_ucl.backend then - redis_params = lua_redis.try_load_redis_servers(classifier_ucl.backend, rspamd_config, true) + -- Try load from statfile options + if statfile_ucl.redis then + redis_params = lua_redis.try_load_redis_servers(statfile_ucl.redis, rspamd_config, true) end - -- Try load from statfile options if not redis_params then if statfile_ucl then redis_params = lua_redis.try_load_redis_servers(statfile_ucl, rspamd_config, true) end end - -- Load directly from classifier config + -- Try load from classifier config + if not redis_params and classifier_ucl.backend then + redis_params = lua_redis.try_load_redis_servers(classifier_ucl.backend, rspamd_config, true) + end + + if not redis_params and classifier_ucl.redis then + redis_params = lua_redis.try_load_redis_servers(classifier_ucl.redis, rspamd_config, true) + end + + if not redis_params then + redis_params = lua_redis.try_load_redis_servers(classifier_ucl, rspamd_config, true) + end + + -- Try load global options if not redis_params then - redis_params = lua_redis.try_load_redis_servers(classifier_ucl, rspamd_config, false, "statistics") + redis_params = lua_redis.try_load_redis_servers(rspamd_config:get_all_opt('redis'), rspamd_config, true) end if not redis_params then @@ -140,4 +153,4 @@ exports.lua_bayes_init_statfile = function(classifier_ucl, statfile_ucl, symbol, return gen_classify_functor(redis_params, classify_script_id), gen_learn_functor(redis_params, learn_script_id) end -return exports
\ No newline at end of file +return exports |