summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-09 16:33:47 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-09 16:33:47 +0100
commit1bb9f099f6c348f56067b57ed3dafa9d3cd6c466 (patch)
tree3f37514d8b6c95a0088c066f2cb19d49f4448264 /src
parentf0803d058f4d24652e185aa410cd5acbcf3f6e10 (diff)
downloadrspamd-1bb9f099f6c348f56067b57ed3dafa9d3cd6c466.tar.gz
rspamd-1bb9f099f6c348f56067b57ed3dafa9d3cd6c466.zip
Document lua_redis.
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_redis.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 47608fa36..01b4493bd 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -32,6 +32,25 @@
/***
* This module implements redis asynchronous client for rspamd LUA API.
+ * Here is an example of using of this module:
+ * @example
+local rspamd_redis = require "rspamd_redis"
+local rspamd_logger = require "rspamd_logger"
+
+local function symbol_callback(task)
+ local redis_key = 'some_key'
+ local function redis_cb(task, err, data)
+ if not err then
+ rspamd_logger.infox('redis returned %1=%2', redis_key, data)
+ end
+ end
+
+ rspamd_redis.make_request(task, "127.0.0.1:6379", redis_cb,
+ 'GET', {redis_key})
+ -- or in table form:
+ -- rspamd_redis.make_request({task=task, host="127.0.0.1:6379,
+ -- callback=redis_cb, timeout=2.0, cmd='GET', args={redis_key}})
+end
*/
LUA_FUNCTION_DEF (redis, make_request);
@@ -256,15 +275,16 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd,
ud->nargs = top;
ud->args = args;
}
-/**
- * Make request to redis server
- * @param task worker task object
- * @param server server to check
- * @param port port of redis server
- * @param callback callback to be called
- * @param request request line
- * @param args list of arguments
- * @return
+/***
+ * @function rspamd_redis.make_request({params})
+ * Make request to redis server, params is a table of key=value arguments in any order
+ * @param {task} task worker task object
+ * @param {ip} host server address
+ * @param {function} callback callback to be called in form `function (task, err, data)`
+ * @param {string} cmd command to be sent to redis
+ * @param {table} args numeric array of strings used as redis arguments
+ * @param {number} timeout timeout in seconds for request (1.0 by default)
+ * @return {boolean} `true` if a request has been scheduled
*/
static int
lua_redis_make_request (lua_State *L)