Skip to content

Commit c9cf56d

Browse files
committed
Apply suggestions from the review
1 parent 3fcb8be commit c9cf56d

File tree

7 files changed

+34
-29
lines changed

7 files changed

+34
-29
lines changed

doc/dev_guide/internals/box_protocol.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ The binary protocol provides complete access to Tarantool functionality, includi
2525
Since version :doc:`2.11.0 </release/2.11.0>`, you can use the :ref:`box.iproto <box_iproto>` submodule to access
2626
IPROTO constants and features from Lua. The submodule enables to :ref:`send arbitrary IPROTO packets <reference_lua-box_iproto_send>`
2727
over the session's socket and :ref:`override the behavior <reference_lua-box_iproto_override>` for all IPROTO
28-
request types (including the :ref:`unknown <box_iproto-unknown>` types).
28+
request types. Also, :ref:`IPROTO_UNKNOWN <box_iproto-unknown>` constant is introduced. The constant is used for the
29+
:ref:`box.iproto.override() <reference_lua-box_iproto_override>` API, which allows setting a handler for incoming requests with an unknown type.
2930

3031
.. toctree::
3132
:maxdepth: 1

doc/dev_guide/internals/iproto/requests.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Overview
3838
- 0x8XXX |br| MP_INT
3939
- Error response
4040

41-
* - :ref:`IPROTO_UNKNOWN <internals-iproto-keys-unknown>`
41+
* - :ref:`IPROTO_UNKNOWN <internals-iproto-unknown>`
4242
- -1 |br| MP_UINT
43-
- Unknown request type. The constant is used only for IPROTO handler :ref:`overriding <reference_lua-box_iproto_override>`.
43+
- Unknown request type
4444

4545
* - :ref:`IPROTO_SELECT <box_protocol-select>`
4646
- 0x01
@@ -139,7 +139,7 @@ Since :doc:`2.11.0 </release/2.11.0>`.
139139

140140
Code: -1.
141141

142-
Unknown request type. The constant is used for overriding an unknown IPROTO request handler.
142+
Unknown request type. The constant is used to override the handler of unknown IPROTO request types.
143143
Learn more: :ref:`box.iproto.override() <reference_lua-box_iproto_override>` and :ref:`box_box_iproto_override <box_iproto_override>`.
144144

145145
.. _box_protocol-select:

doc/dev_guide/reference_capi/box.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@
324324
:param uint32_t request_type: IPROTO request type code (for example, ``IPROTO_SELECT``).
325325
For details, check :ref:`Client-server requests and responses <internals-requests_responses>`.
326326
327-
To override the handler of an unknown request type, use the :ref:`IPROTO_UNKNOWN <internals-iproto-keys-unknown>` type code.
327+
To override the handler of unknown request types, use the :ref:`IPROTO_UNKNOWN <internals-iproto-keys-unknown>` type code.
328328
329329
:param iproto_handler_t handler: IPROTO request handler. To reset the request handler, set the ``handler`` parameter to ``NULL``.
330330
See the full parameter description in the :ref:`Handler function <box_box_iproto_override-handler>` section.
@@ -343,11 +343,11 @@
343343
344344
**Possible errors:**
345345
346-
If the Lua handler throws an exception, the behavior is similar to a remote procedure call.
346+
If a Lua handler throws an exception, the behavior is similar to that of a remote procedure call.
347347
The following errors are returned to the client over IPROTO (see `src/lua/utils.h <https://github.com/tarantool/tarantool/blob/dec0e0221e183fa972efa65bb0fb658112f2196f/src/lua/utils.h#L366-L371>`__):
348348
349-
* :errcode:`ER_PROC_LUA` -- the exception is thrown, diagnostic is not set.
350-
* diagnostics from ``src/box/errcode.h`` -- the exception is thrown, diagnostic is set.
349+
* :errcode:`ER_PROC_LUA` -- an exception is thrown from a Lua handler, diagnostic is not set.
350+
* diagnostics from ``src/box/errcode.h`` -- an exception is thrown, diagnostic is set.
351351
352352
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.
353353
@@ -378,14 +378,17 @@
378378
379379
The handler returns a status code. Possible statuses:
380380
381-
* ``IPROTO_REQUEST_HANDLER_OK`` -- success
382-
* ``IPROTO_REQUEST_HANDLER_ERROR`` -- error, diagnostic must be set by handler
383-
* ``IPROTO_REQUEST_HANDLER_FALLBACK`` -- fallback to the system handler
381+
* ``IPROTO_REQUEST_HANDLER_OK`` -- success
382+
* ``IPROTO_REQUEST_HANDLER_ERROR`` -- error, diagnostic must be set by handler
383+
(see :ref:`box_error_set() <c_api-error-box_error_set>` and :ref:`box_error_raise() <c_api-error-box_error_raise>`)
384+
385+
* ``IPROTO_REQUEST_HANDLER_FALLBACK`` -- fallback to the default handler
384386
385387
.. _box_box_iproto_override-destroy:
386388
387389
**Handler destructor function**
388390
391+
The destructor is called when the handler is reset.
389392
The signature of a destructor function (the ``destroy`` parameter):
390393
391394
.. code-block:: c

doc/dev_guide/reference_capi/error.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
6565
Clear the last error.
6666
67+
.. _c_api-error-box_error_set:
68+
6769
.. c:function:: int box_error_set(const char *file, unsigned line, uint32_t code, const char *format, ...)
6870
6971
Set the last error.
@@ -76,6 +78,8 @@
7678
7779
See also: IPROTO :ref:`error code<capi-box_error_code>`
7880
81+
.. _c_api-error-box_error_raise:
82+
7983
.. c:macro:: box_error_raise(code, format, ...)
8084
8185
A backward-compatible API define.

doc/reference/reference_lua/box_iproto.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Submodule box.iproto
66
Since :doc:`2.11.0 </release/2.11.0>`.
77

88
The ``box.iproto`` submodule provides the ability to work with the network subsystem of Tarantool.
9-
It enables to extend :ref:`IPROTO <box_protocol>` functionality from the Lua libraries.
9+
It allows you to extend the :ref:`IPROTO <box_protocol>` functionality from Lua.
1010
With this submodule, you can:
1111

1212
* :ref:`parse the unknown IPROTO requests types <reference_lua-box_iproto_override>`
1313
* :ref:`send arbitrary IPROTO packets <reference_lua-box_iproto_send>`
14-
* :ref:`override the behavior <reference_lua-box_iproto_override>` of the existing request types in the binary protocol
14+
* :ref:`override the behavior <reference_lua-box_iproto_override>` of the existing and unknown request types in the binary protocol
1515

1616
The submodule exports all IPROTO :ref:`constants <internals-box_protocol>` and :ref:`features <internals-iproto-keys-features>` to Lua.
1717

@@ -61,7 +61,7 @@ The submodule exports:
6161

6262
**Example**
6363

64-
The example converts the feature names from the ``box.iproto.protocol_features`` set into codes:
64+
The example converts the feature names from ``box.iproto.protocol_features`` set into codes:
6565

6666
.. code-block:: lua
6767
@@ -89,7 +89,7 @@ Handling the unknown IPROTO request types
8989
Every IPROTO request has a static handler.
9090
That is, before version :doc:`2.11.0 </release/2.11.0>`, any unknown request raised an error.
9191
Since :doc:`2.11.0 </release/2.11.0>`, a new request type is introduced -- :ref:`IPROTO_UNKNOWN <internals-iproto-keys-unknown>`.
92-
This type is used to override the handlers of the unknown IPROTO requests types. For details, see
92+
This type is used to override the handlers of the unknown IPROTO request types. For details, see
9393
:ref:`box.iproto.override() <reference_lua-box_iproto_override>` and :ref:`box_iproto_override <box_box_iproto_override>` functions.
9494

9595
.. _box_iproto-reference:

doc/reference/reference_lua/box_iproto/override.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _reference_lua-box_iproto_override:
1+
.. _reference_lua-box_iproto_override:
22

33
box.iproto.override()
44
=====================
@@ -13,31 +13,32 @@ box.iproto.override()
1313
:param number request_type: a request type code. Possible values:
1414

1515
* a type code from :ref:`box.iproto.type <reference_lua-box_iproto_type>` (except
16-
``box.iproto.type.UNKNOWN``) -- override the existing request type.
16+
``box.iproto.type.UNKNOWN``) -- override the existing request type handler.
1717

18-
* ``box.iproto.type.UNKNOWN`` -- override an unknown request type.
18+
* ``box.iproto.type.UNKNOWN`` -- override the handler of unknown request types.
1919

2020
:param function handler: IPROTO request handler.
2121
The signature of a handler function: ``function(sid, header, body)``, where
2222

2323
* ``sid`` (number): current IPROTO session identifier (see :ref:`box.session.id() <box_session-id>`)
24-
* ``header`` (userdata): a request header encoded as :ref:`msgpack_object <msgpack-object-methods>`
25-
* ``body`` (userdata): a request body encoded as :ref:`msgpack_object <msgpack-object-methods>`
24+
* ``header`` (userdata): a request header encoded as a :ref:`msgpack_object <msgpack-object-methods>`
25+
* ``body`` (userdata): a request body encoded as a :ref:`msgpack_object <msgpack-object-methods>`
2626

27-
Returns ``true`` on success, otherwise ``false``. In case of failure, there is a fallback
28-
to the system handler.
27+
Returns ``true`` on success, otherwise ``false``. On ``false``, there is a fallback
28+
to the default handler. Also, you can indicate an error by throwing an exception.
29+
In this case, the return value is ``false``, but this does not always means a failure.
2930

3031
To reset the request handler, set the ``handler`` parameter to ``nil``.
3132

3233
:return: none
3334

3435
**Possible errors:**
3536

36-
If the Lua handler throws an exception, the behavior is similar to a remote procedure call.
37+
If a Lua handler throws an exception, the behavior is similar to that of a remote procedure call.
3738
The following errors are returned to the client over IPROTO (see `src/lua/utils.h <https://github.com/tarantool/tarantool/blob/dec0e0221e183fa972efa65bb0fb658112f2196f/src/lua/utils.h#L366-L371>`__):
3839

39-
* :errcode:`ER_PROC_LUA` -- the exception is thrown, diagnostic is not set.
40-
* diagnostics from ``src/box/errcode.h`` -- the exception is thrown, diagnostic is set.
40+
* :errcode:`ER_PROC_LUA` -- an exception is thrown from a Lua handler, diagnostic is not set.
41+
* diagnostics from ``src/box/errcode.h`` -- an exception is thrown, diagnostic is set.
4142

4243
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.
4344

doc/reference/reference_lua/box_iproto/send.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,3 @@ box.iproto.send()
6262
sync = 10,
6363
schema_version = box.info.schema_version}))
6464
65-
66-
67-
68-

0 commit comments

Comments
 (0)