Skip to content

Commit 172d7cb

Browse files
authored
vshard.router.map_callrw() supports the return_raw option (#2804)
Add description of supporting the return_raw option in vshard Closes #2609
1 parent 7ba54bd commit 172d7cb

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

doc/reference/reference_rock/vshard/vshard_router.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,11 @@ Router public API
325325
:param argument_list: an array of the function's arguments
326326
:param options:
327327

328-
* ``timeout``a request timeout, in seconds. The timeout is for the entire ``map_callrw()``, including all its stages.
328+
* ``timeout``---a request timeout, in seconds. The timeout is for the entire ``map_callrw()``, including all its stages.
329329

330-
``timeout`` is the only supported option.
330+
* ``return_raw``---the :ref:`net.box option <net_box-options>` implemented in Tarantool since version 2.10.0.
331+
If set to ``true``, ``net.box`` returns the response data wrapped in a :ref:`MessagePack object <msgpack-object-info>` instead of decoding it to Lua.
332+
For more details, see the **Return** section below.
331333

332334
.. important::
333335

@@ -345,6 +347,27 @@ Router public API
345347
If the function returns ``nil`` or ``box.NULL`` from one of the storages,
346348
it will not be present in the resulting map.
347349

350+
If the ``return_raw`` option is used,
351+
the result is a map of the following format: ``{[replicaset_uuid] = msgpack.object}``
352+
where ``msgpack.object`` is an object that stores a MessagePack array with the results returned from the storage map function.
353+
354+
The option use case is the same as in using ``net.box``: to avoid decoding of the call results into Lua.
355+
The option can be helpful if a router is used as a proxy and results received from a storage are big.
356+
357+
Example:
358+
359+
.. code-block:: lua
360+
361+
local res = vshard.router.map_callrw('my_func', args, {..., return_raw = true})
362+
363+
for replicaset_uuid, msgpack_value in pairs(res) do
364+
log.info('Replicaset %s returned %s', replicaset_uuid,
365+
msgpack_value:decode())
366+
end
367+
368+
This is an illustration of the option usage.
369+
Normally, you don't need to use ``return_raw`` if you call the :ref:`decode() <msgpack-decode_string>` function.
370+
348371
* On failure: ``nil``, error object, and optional replica set UUID where the error occurred.
349372
UUID will not be returned if the error is not related to a particular replica set.
350373
For instance, the method fails if not all buckets were found, even if all replica sets were scanned successfully.
@@ -365,6 +388,8 @@ Router public API
365388
end
366389
end
367390
391+
If the ``return_raw`` option is used, the result on failure is the same as described above.
392+
368393
Map-Reduce in vshard can be divided into three stages: Ref, Map, and Reduce.
369394

370395
**Ref and Map**. ``map_callrw()`` combines both the Ref and the Map stages.

0 commit comments

Comments
 (0)