Skip to content

Commit e97085d

Browse files
authored
Add note about async requests in net_box triggers (#3603)
Resolves #2979
1 parent 95e0690 commit e97085d

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

doc/reference/reference_lua/net_box.rst

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ Below is a list of all ``net.box`` functions.
470470
.. method:: conn.space.<space-name>:upsert({field-value, ...} [, {options}])
471471

472472
:samp:`conn.space.{space-name}:upsert(...)` is the remote-call equivalent
473-
of the local call :samp:`box.space.{space-name}:upsert(...)`. (:ref:`see details <box_space-upsert>`)
473+
of the local call :samp:`box.space.{space-name}:upsert(...)`. (:ref:`see details <box_space-upsert>`).
474474
For an additional option see :ref:`Module buffer and skip-header <buffer-module_and_skip_header>`.
475475

476476
.. _conn-delete:
@@ -794,16 +794,20 @@ With the ``net.box`` module, you can use the following
794794

795795
Define a trigger for execution when a new connection is established, and authentication
796796
and schema fetch are completed due to an event such as ``net_box.connect``.
797+
798+
If a trigger function issues ``net_box`` requests, they must be :ref:`asynchronous <net_box-is_async>`
799+
(``{is_async = true}``). An attempt to wait for request completion with ``future:pairs()``
800+
or ``future:wait_result()`` in the trigger function will result in an error.
801+
797802
If the trigger execution fails and an exception happens, the connection's
798803
state changes to 'error'. In this case, the connection is terminated, regardless of the
799804
``reconnect_after`` option's value. Can be called as many times as
800805
reconnection happens, if ``reconnect_after`` is greater than zero.
801806

802-
:param function trigger-function: function which will become the trigger
803-
function. Takes the ``conn``
804-
object as the first argument
805-
:param function old-trigger-function: existing trigger function which will
806-
be replaced by trigger-function
807+
:param function trigger-function: the trigger function. Takes the ``conn``
808+
object as the first argument.
809+
:param function old-trigger-function: an existing trigger function to replace
810+
with ``trigger-function``
807811
:return: nil or function pointer
808812

809813
.. _net_box-on_disconnect:
@@ -815,11 +819,11 @@ With the ``net.box`` module, you can use the following
815819
Execution stops after a connection is explicitly closed, or once the Lua
816820
garbage collector removes it.
817821

818-
:param function trigger-function: function which will become the trigger
822+
:param function trigger-function: the trigger
819823
function. Takes the ``conn``
820824
object as the first argument
821-
:param function old-trigger-function: existing trigger function which will
822-
be replaced by trigger-function
825+
:param function old-trigger-function: an existing trigger function to replace
826+
with ``trigger-function``
823827
:return: nil or function pointer
824828

825829
.. _net_box-on_shutdown:
@@ -845,11 +849,10 @@ With the ``net.box`` module, you can use the following
845849
just close the connection abruptly.
846850
In this case, the ``on_shutdown()`` trigger is not executed.
847851

848-
:param function trigger-function: function which will become the trigger
849-
function. Takes the ``conn``
852+
:param function trigger-function: the trigger function. Takes the ``conn``
850853
object as the first argument
851-
:param function old-trigger-function: existing trigger function which will
852-
be replaced by trigger-function
854+
:param function old-trigger-function: an existing trigger function to replace
855+
with ``trigger-function``
853856
:return: nil or function pointer
854857

855858
.. _net_box-on_schema_reload:
@@ -860,11 +863,14 @@ With the ``net.box`` module, you can use the following
860863
server after schema has been updated. So, if a server request fails due to a
861864
schema version mismatch error, schema reload is triggered.
862865

863-
:param function trigger-function: function which will become the trigger
864-
function. Takes the ``conn``
866+
If a trigger function issues ``net_box`` requests, they must be :ref:`asynchronous <net_box-is_async>`
867+
(``{is_async = true}``). An attempt to wait for request completion with ``future:pairs()``
868+
or ``future:wait_result()`` in the trigger function will result in an error.
869+
870+
:param function trigger-function: the trigger function. Takes the ``conn``
865871
object as the first argument
866-
:param function old-trigger-function: existing trigger function which will
867-
be replaced by trigger-function
872+
:param function old-trigger-function: an existing trigger function to replace
873+
with ``trigger-function``
868874
:return: nil or function pointer
869875

870876
.. NOTE::
@@ -875,5 +881,5 @@ With the ``net.box`` module, you can use the following
875881
If both parameters are omitted, then the response is a list of
876882
existing trigger functions.
877883

878-
Details about trigger characteristics are in the
884+
Find the detailed information about triggers in the
879885
:ref:`triggers <triggers-box_triggers>` section.

0 commit comments

Comments
 (0)