summaryrefslogtreecommitdiffstats
path: root/lualib/lua_redis.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-19 13:42:23 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-19 13:42:23 +0100
commit994f9676d2c016bb07ec53a0018aaa888ebe2d27 (patch)
treec66cae234c4942de34a16fd571f305c498a07fac /lualib/lua_redis.lua
parent91466aa2a1abffd923615a6b9315bd71e7b96ac0 (diff)
downloadrspamd-994f9676d2c016bb07ec53a0018aaa888ebe2d27.tar.gz
rspamd-994f9676d2c016bb07ec53a0018aaa888ebe2d27.zip
[Minor] Add support of read only redis params
Diffstat (limited to 'lualib/lua_redis.lua')
-rw-r--r--lualib/lua_redis.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua
index 1be476fbe..bb229479c 100644
--- a/lualib/lua_redis.lua
+++ b/lualib/lua_redis.lua
@@ -32,6 +32,7 @@ local function try_load_redis_servers(options, rspamd_config, result)
local default_timeout = 1.0
local default_expand_keys = false
local upstream_list = require "rspamd_upstream_list"
+ local read_only = true
-- Try to get read servers:
local upstreams_read, upstreams_write
@@ -51,6 +52,7 @@ local function try_load_redis_servers(options, rspamd_config, result)
else
upstreams_read = upstream_list.create(options['servers'], default_port)
end
+ read_only = false
elseif options['server'] then
if rspamd_config then
upstreams_read = upstream_list.create(rspamd_config,
@@ -58,18 +60,20 @@ local function try_load_redis_servers(options, rspamd_config, result)
else
upstreams_read = upstream_list.create(options['server'], default_port)
end
+ read_only = false
end
if upstreams_read then
if options['write_servers'] then
if rspamd_config then
upstreams_write = upstream_list.create(rspamd_config,
- options['write_servers'], default_port)
+ options['write_servers'], default_port)
else
upstreams_write = upstream_list.create(options['write_servers'],
- default_port)
+ default_port)
end
- elseif not options['read_servers'] then
+ read_only = false
+ elseif not read_only then
upstreams_write = upstreams_read
end
end
@@ -106,6 +110,12 @@ local function try_load_redis_servers(options, rspamd_config, result)
result['password'] = options['password']
end
+ if read_only and not result.write_servers then
+ result.read_only = true
+ elseif result.write_servers then
+ result.read_only = false
+ end
+
if upstreams_read then
result.read_servers = upstreams_read
if upstreams_write then