commit 4da87a5: [Minor] Have bayes use global redis settings

Andrew Lewis nerf at judo.za.org
Mon Jul 29 17:50:16 UTC 2024


Author: Andrew Lewis
Date: 2023-12-12 09:52:45 +0200
URL: https://github.com/rspamd/rspamd/commit/4da87a5cdaa931a7e0e716b8095594d3cdae0287 (refs/pull/4739/head)

[Minor] Have bayes use global redis settings

---
 lualib/lua_bayes_redis.lua | 25 +++++++++++++++++++------
 1 file 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


More information about the Commits mailing list