diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-14 10:57:47 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-14 14:45:25 +0000 |
commit | ab0415eae0c90b343f12cb9111fef47c073559f0 (patch) | |
tree | 2b2962d802fcf1f76ff2a0ca8e5c801180c804ac /lualib/lua_redis.lua | |
parent | faef0fc58264fcd72a8b52a4e7403895383bd714 (diff) | |
download | rspamd-ab0415eae0c90b343f12cb9111fef47c073559f0.tar.gz rspamd-ab0415eae0c90b343f12cb9111fef47c073559f0.zip |
[Minor] Allow to specify extra options on Redis requests
Diffstat (limited to 'lualib/lua_redis.lua')
-rw-r--r-- | lualib/lua_redis.lua | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua index 1e53c6b6c..10c333da0 100644 --- a/lualib/lua_redis.lua +++ b/lualib/lua_redis.lua @@ -469,7 +469,9 @@ end -- callback - function to be called upon request is completed -- command - redis command -- args - table of arguments -local function rspamd_redis_make_request(task, redis_params, key, is_write, callback, command, args) +-- extra_opts - table of optional request arguments +local function rspamd_redis_make_request(task, redis_params, key, is_write, + callback, command, args, extra_opts) local addr local function rspamd_redis_make_request_cb(err, data) if err then @@ -521,6 +523,12 @@ local function rspamd_redis_make_request(task, redis_params, key, is_write, call args = args } + if extra_opts then + for k,v in pairs(extra_opts) do + options[k] = v + end + end + if redis_params['password'] then options['password'] = redis_params['password'] end @@ -542,7 +550,8 @@ end exports.rspamd_redis_make_request = rspamd_redis_make_request exports.redis_make_request = rspamd_redis_make_request -local function redis_make_request_taskless(ev_base, cfg, redis_params, key, is_write, callback, command, args) +local function redis_make_request_taskless(ev_base, cfg, redis_params, key, + is_write, callback, command, args, extra_opts) if not ev_base or not redis_params or not callback or not command then return false,nil,nil end @@ -586,6 +595,12 @@ local function redis_make_request_taskless(ev_base, cfg, redis_params, key, is_w cmd = command, args = args } + if extra_opts then + for k,v in pairs(extra_opts) do + options[k] = v + end + end + if redis_params['password'] then options['password'] = redis_params['password'] |