diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-18 14:18:04 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-18 14:18:41 +0100 |
commit | d61a9525f01ef6a410d34c5132294de21fdb4ca0 (patch) | |
tree | 8d7f85f3360b88a90794d6afb8c4435f5c31d17a | |
parent | a33175dd4ef4b8165f555490e28fbd0b8ef8b74c (diff) | |
download | rspamd-d61a9525f01ef6a410d34c5132294de21fdb4ca0.tar.gz rspamd-d61a9525f01ef6a410d34c5132294de21fdb4ca0.zip |
[Feature] Read redis backend statistics configuration from global section
Issue: #766
-rw-r--r-- | src/libstat/backends/redis_backend.c | 20 | ||||
-rw-r--r-- | src/libstat/learn_cache/redis_cache.c | 21 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index 83517ba64..4ff9b08b1 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -1050,6 +1050,26 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx, stf->symbol); } + /* Now try global redis settings */ + if (!ret) { + obj = ucl_object_lookup (cfg->rcl_obj, "redis"); + + if (obj) { + const ucl_object_t *specific_obj; + + specific_obj = ucl_object_lookup (obj, "statistics"); + + if (specific_obj) { + ret = rspamd_redis_try_ucl (backend, specific_obj, cfg, + stf->symbol); + } + else { + ret = rspamd_redis_try_ucl (backend, obj, cfg, + stf->symbol); + } + } + } + if (!ret) { msg_err_config ("cannot init redis backend for %s", stf->symbol); g_slice_free1 (sizeof (*backend), backend); diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c index 473bee8ec..cd92bfac4 100644 --- a/src/libstat/learn_cache/redis_cache.c +++ b/src/libstat/learn_cache/redis_cache.c @@ -320,6 +320,27 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx, stf->symbol); } + /* Now try global redis settings */ + if (!ret) { + obj = ucl_object_lookup (cfg->rcl_obj, "redis"); + + if (obj) { + const ucl_object_t *specific_obj; + + specific_obj = ucl_object_lookup (obj, "statistics"); + + if (specific_obj) { + ret = rspamd_redis_cache_try_ucl (cache_ctx, specific_obj, cfg, + stf->symbol); + } + else { + ret = rspamd_redis_cache_try_ucl (cache_ctx, obj, cfg, + stf->symbol); + } + } + } + + if (!ret) { msg_err_config ("cannot init redis cache for %s", stf->symbol); g_slice_free1 (sizeof (*cache_ctx), cache_ctx); |