|
1 |
| -.. _net_box-module: |
| 1 | +.. _net_box-module: |
2 | 2 |
|
3 | 3 | --------------------------------------------------------------------------------
|
4 | 4 | Module `net.box`
|
@@ -40,13 +40,22 @@ Most ``net.box`` methods accept the last ``{options}`` argument, which can be:
|
40 | 40 | * ``{timeout=...}``. For example, a method whose last argument is
|
41 | 41 | ``{timeout=1.5}`` will stop after 1.5 seconds on the local node, although this
|
42 | 42 | 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 | + |
44 | 46 | * ``{is_async=...}``. For example, a method whose last argument is
|
45 | 47 | ``{is_async=true}`` will not wait for the result of a request. See the
|
46 | 48 | :ref:`is_async <net_box-is_async>` description.
|
| 49 | + |
47 | 50 | * ``{on_push=... on_push_ctx=...}``. For receiving out-of-band messages.
|
48 | 51 | See the :doc:`/reference/reference_lua/box_session/push` description.
|
49 | 52 |
|
| 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 | + |
50 | 59 | The diagram below shows possible connection states and transitions:
|
51 | 60 |
|
52 | 61 | .. ifconfig:: builder not in ('latex', )
|
@@ -523,9 +532,9 @@ Below is a list of all ``net.box`` functions.
|
523 | 532 | timeout expires: the timeout expiration only aborts the wait for the remote
|
524 | 533 | server response, not the request itself.
|
525 | 534 |
|
526 |
| - .. _net_box-is_async: |
| 535 | + .. _net_box-is_async: |
527 | 536 |
|
528 |
| - .. method:: request(... {is_async=...}) |
| 537 | + .. method:: request(... {is_async=...}) |
529 | 538 |
|
530 | 539 | ``{is_async=true|false}`` is an option which is applicable for all
|
531 | 540 | ``net_box`` requests including ``conn:call``, ``conn:eval``, and the
|
@@ -602,7 +611,32 @@ Below is a list of all ``net.box`` functions.
|
602 | 611 | the result of a sync request, it is structured differently: as a
|
603 | 612 | table, instead of as the unpacked values.
|
604 | 613 |
|
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: |
606 | 640 |
|
607 | 641 | ============================================================================
|
608 | 642 | Triggers
|
|
0 commit comments