MINOR: hlua: support for optional arguments to core.register_task()
core.register_task(function) may now take up to 4 additional arguments
that will be passed as-is to the task function.
This could be convenient to spawn sub-tasks from existing functions
supporting core.register_task() without the need to use global
variables to pass some context to the newly created task function.
The new prototype is:
core.register_task(function[, arg1[, arg2[, ...[, arg4]]]])
Implementation remains backward-compatible with existing scripts.
diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst
index 146c050..917b684 100644
--- a/doc/lua-api/index.rst
+++ b/doc/lua-api/index.rst
@@ -720,7 +720,7 @@
It takes no input, and no output is expected.
-.. js:function:: core.register_task(func)
+.. js:function:: core.register_task(func[, arg1[, arg2[, ...[, arg4]]]])
**context**: body, init, task, action, sample-fetch, converter
@@ -728,16 +728,19 @@
main scheduler starts. For example this type of tasks can be executed to
perform complex health checks.
- :param function func: is the Lua function called to work as initializer.
+ :param function func: is the Lua function called to work as an async task.
+
+ Up to 4 optional arguments (all types supported) may be passed to the function.
+ (They will be passed as-is to the task function)
The prototype of the Lua function used as argument is:
.. code-block:: lua
- function()
+ function([arg1[, arg2[, ...[, arg4]]]])
..
- It takes no input, and no output is expected.
+ It takes up to 4 optional arguments (provided when registering), and no output is expected.
.. js:function:: core.register_cli([path], usage, func)