From: Vsevolod Stakhov Date: Wed, 14 Feb 2018 10:57:47 +0000 (+0000) Subject: [Minor] Allow to specify extra options on Redis requests X-Git-Tag: 1.7.0~191 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ab0415eae0c90b343f12cb9111fef47c073559f0;p=rspamd.git [Minor] Allow to specify extra options on Redis requests --- 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']