]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Read redis backend statistics configuration from global section
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 18 Aug 2016 13:18:04 +0000 (14:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 18 Aug 2016 13:18:41 +0000 (14:18 +0100)
Issue: #766

src/libstat/backends/redis_backend.c
src/libstat/learn_cache/redis_cache.c

index 83517ba64643a911103c53e1194ca48dc090d6ca..4ff9b08b106def4c1d10e0cb972e9b49c89860e6 100644 (file)
@@ -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);
index 473bee8ec5703fd51dcf9a4234684d694f6af0ac..cd92bfac4b0a027a597499e86a6b53c16e2cc73d 100644 (file)
@@ -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);