Skip to content

Commit 6dd1848

Browse files
xuniqpatiencedaur
andauthored
Document return_raw net.box option (#2739)
Fixes #2506 Co-authored-by: Patience Daur <[email protected]>
1 parent 6e24105 commit 6dd1848

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

doc/reference/reference_lua/net_box.rst

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _net_box-module:
1+
.. _net_box-module:
22

33
--------------------------------------------------------------------------------
44
Module `net.box`
@@ -40,13 +40,22 @@ Most ``net.box`` methods accept the last ``{options}`` argument, which can be:
4040
* ``{timeout=...}``. For example, a method whose last argument is
4141
``{timeout=1.5}`` will stop after 1.5 seconds on the local node, although this
4242
does not guarantee that execution will stop on the remote server node.
43-
* ``{buffer=...}``. For an example see :ref:`buffer module <buffer-module>`.
43+
44+
* ``{buffer=...}``. For an example, see the :ref:`buffer module <buffer-module>`.
45+
4446
* ``{is_async=...}``. For example, a method whose last argument is
4547
``{is_async=true}`` will not wait for the result of a request. See the
4648
:ref:`is_async <net_box-is_async>` description.
49+
4750
* ``{on_push=... on_push_ctx=...}``. For receiving out-of-band messages.
4851
See the :doc:`/reference/reference_lua/box_session/push` description.
4952

53+
* ``{return_raw=...}`` (since version 2.10.0).
54+
If set to ``true``, net.box returns response data wrapped
55+
in a :ref:`MsgPack object <msgpack-object-info>` instead of decoding it to Lua.
56+
The default value is ``false``.
57+
For an example, see option description :ref:`below <net_box-return_raw>`.
58+
5059
The diagram below shows possible connection states and transitions:
5160

5261
.. ifconfig:: builder not in ('latex', )
@@ -523,9 +532,9 @@ Below is a list of all ``net.box`` functions.
523532
timeout expires: the timeout expiration only aborts the wait for the remote
524533
server response, not the request itself.
525534

526-
.. _net_box-is_async:
535+
.. _net_box-is_async:
527536

528-
.. method:: request(... {is_async=...})
537+
.. method:: request(... {is_async=...})
529538

530539
``{is_async=true|false}`` is an option which is applicable for all
531540
``net_box`` requests including ``conn:call``, ``conn:eval``, and the
@@ -602,7 +611,32 @@ Below is a list of all ``net.box`` functions.
602611
the result of a sync request, it is structured differently: as a
603612
table, instead of as the unpacked values.
604613

605-
.. _net_box-triggers:
614+
.. _net_box-return_raw:
615+
616+
.. method:: request(... {return_raw=...})
617+
618+
``{return_raw=true}`` is ignored for:
619+
620+
* Methods that return ``nil``:
621+
``begin``, ``commit``, ``rollback``, ``upsert``, ``prepare``.
622+
623+
* ``index.count`` (returns number).
624+
625+
For ``execute``, the option is applied only to data (`rows`). Metadata is decoded even if ``{return_raw=true}``.
626+
627+
**Example:**
628+
629+
.. code-block:: lua
630+
631+
local c = require('net.box').connect(uri)
632+
local mp = c.eval('eval ...', {1, 2, 3}, {return_raw = true})
633+
mp:decode() -- {1, 2, 3}
634+
635+
The option can be useful if you want to pass a response through without decoding or with partial decoding.
636+
The usage of :ref:`MsgPack object <msgpack-object-info>` can reduce pressure on the Lua garbage collector.
637+
638+
639+
.. _net_box-triggers:
606640

607641
============================================================================
608642
Triggers

0 commit comments

Comments
 (0)