Skip to content

Commit f541463

Browse files
committed
Update files after review
1 parent 0a079e4 commit f541463

File tree

5 files changed

+103
-19
lines changed

5 files changed

+103
-19
lines changed

doc/dev_guide/reference_capi/box.rst

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@
251251
252252
Since version :doc:`2.11.0 </release/2.11.0>`.
253253
Send an :ref:`IPROTO <internals-iproto-format>` packet over the session's socket with the given MsgPack header
254-
and body. NB: yields.
254+
and body.
255+
The function yields.
255256
The function works for binary sessions only. For details, see :ref:`box.session.type() <box_session-type>`.
256257
257258
:param uint32_t sid: IPROTO session identifier (see :ref:`box_session_id() <box_box_session_id>`)
@@ -261,25 +262,49 @@
261262
:param char* body_end: end of a body encoded as MsgPack
262263
263264
:return: 0 on success
264-
:return: 1 if there is a failure
265+
:return: -1 on error (check :ref:`box_error_last() <c_api-error-box_error_last>`)
265266
:rtype: number
266267
267268
See also :ref:`box.iproto.send() <reference_lua-box_iproto_send>`
268269
270+
**Possible errors:**
271+
272+
* :errcode:`ER_SESSION_CLOSED` -- the session is closed.
273+
* :errcode:`ER_NO_SUCH_SESSION` -- the session does not exist.
274+
* :errcode:`ER_MEMORY_ISSUE` -- out of memory limit has been reached.
275+
* :errcode:`ER_WRONG_SESSION_TYPE` -- the session type is not binary.
276+
277+
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.
278+
269279
.. _box_box_iproto_override:
270280
271281
.. c:function:: void box_iproto_override(uint32_t request_type, iproto_handler_t handler, iproto_handler_destroy_t destroy, void *ctx)
272282
273283
Since version :doc:`2.11.0 </release/2.11.0>`.
274284
Sets an IPROTO request handler with the provided context for the given request type.
285+
The function yields.
286+
287+
Possible values:
275288
276-
:param uint32_t request_type: request type code from the ``iproto_type`` enumeration
277-
:param iproto_handler_t handler: IPROTO request handler
289+
* a type code from the :ref:`box.iproto.type <reference_lua-box_iproto_type>` (except
290+
``box.iproto.type.UNKNOWN``) -- override the existing request type.
291+
292+
* ``box.iproto.type.UNKNOWN`` -- override an unknown request type.
293+
294+
:param uint32_t request_type: request type code from the ``iproto_type`` enumeration
295+
:param iproto_handler_t handler: IPROTO request handler
278296
:param iproto_handler_destroy_t destroy: IPROTO request handler destructor
279-
:param void* ctx: context passed to handler
297+
:param void* ctx: a context passed to the ``handler`` and ``destroy`` callbacks
280298
281299
:return: 0 on success
282300
:return: -1 on error (check :ref:`box_error_last() <c_api-error-box_error_last>`)
283301
:rtype: number
284302
285-
See also :ref:`box.session.id() <box_session-id>`
303+
See also :ref:`box.iproto.override() <reference_lua-box_iproto_override>`
304+
305+
**Possible errors:**
306+
307+
* :errcode:`ER_PROC_LUA` -- the exception is thrown, diagnostic is not set.
308+
* diagnostics from ``src/box/errcode.h`` -- the exception is thrown, diagnostic is set.
309+
310+
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.

doc/reference/reference_lua/box_iproto.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The ``box.iproto`` submodule provides the ability to work with the network subsy
99
It enables to extend the :ref:`binary protocol <box_protocol>` functionality from the Lua libraries.
1010
With this submodule, you can:
1111

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

@@ -73,7 +73,7 @@ The example converts the feature names from the ``box.iproto.protocol_features``
7373
watchers = true,
7474
}
7575
76-
-- Конвертация имен фич в коды, чтобы вернуть их в ответ на запрос IPROTO_ID.
76+
-- Convert the feature names into codes
7777
features = {}
7878
for name in pairs(box.iproto.protocol_features) do
7979
table.insert(features, box.iproto.feature[name])
@@ -128,7 +128,7 @@ The table lists all available functions and data of the submodule:
128128
- IPROTO protocol :ref:`features <internals-iproto-keys-features>`
129129

130130
* - :doc:`./box_iproto/override`
131-
- Set the IPROTO request handler callbacks
131+
- Set an IPROTO request handler callbacks for the given request type
132132

133133
* - :doc:`./box_iproto/send`
134134
- Send an IPROTO packet over the session's socket

doc/reference/reference_lua/box_iproto/override.rst

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,58 @@
33
box.iproto.override()
44
=====================
55

6+
function(header, body) end
7+
-- @param header userdata @ заголовок запроса в виде msgpack_object
8+
-- (см. модуль msgpack)
9+
-- @param body userdata @ тело запроса в виде msgpack_object
10+
-- (см. модуль msgpack)
11+
-- @a header и @a body можно дополнительно индексировать по IPROTO константам
12+
-- такого же формата как в box.iproto (то есть, в любом регистре без префикса
13+
-- IPROTO).
14+
-- @return boolean @ true, если успех, false для фоллбека на системный обработчик
15+
function(header, body) end
16+
17+
---
18+
-- Перегружает обработчик запроса заданного типа.
19+
-- `box.iproto.type.UNKNOWN` перегружает обработчик неизвестных типов запросов.
20+
-- @param request_type number @ тип обработчика
21+
-- @param handler function @ пользователський обработчик; nil сбрасывает обработчик
22+
-- @return nil
23+
function box.iproto.override(request_type, handler) end
24+
625
.. module:: box.iproto
726

827
.. function:: override(request_type, handler)
928

1029
Since version :doc:`2.11.0 </release/2.11.0>`.
11-
Set the IPROTO request handler callbacks.
30+
Set a new IPROTO request handler callback for the given request type.
31+
32+
:param number request_type: a request type code. Possible values:
33+
34+
* a type code from the :ref:`box.iproto.type <reference_lua-box_iproto_type>` (except
35+
``box.iproto.type.UNKNOWN``) -- override the existing request type.
36+
37+
* ``box.iproto.type.UNKNOWN`` -- override an unknown request type.
38+
39+
40+
:param function handler: IPROTO request handler. To reset the request handler, pass ``nill``.
41+
42+
The handler function has the following syntax:
43+
``function(header, body) end``.
44+
45+
:param userdata header: a header of the request encoded as :ref:`msgpack_object <msgpack-object-methods>`
46+
:param userdata body: a body of the request encoded as :ref:`msgpack_object <msgpack-object-methods>`
47+
:return: true on success
48+
:rtype: boolean
49+
50+
:rtype: nil
51+
52+
**Possible errors:**
1253

13-
:param uint32_t request_type:
14-
:param iproto_handler_t handler:
54+
* :errcode:`ER_PROC_LUA` -- the exception is thrown, diagnostic is not set.
55+
* diagnostics from ``src/box/errcode.h`` -- the exception is thrown, diagnostic is set.
1556

16-
:return: 0 on success or -1 on error (check box_error_last())
17-
:rtype: number
57+
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.
1858

1959
**Example:**
2060

doc/reference/reference_lua/box_iproto/protocol_features.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ box.iproto.protocol_features
88
.. data:: protocol_features
99

1010
The set of IPROTO protocol features supported by the server.
11-
Learn more: `src/box/iproto_features.h <https://github.com/tarantool/tarantool/blob/master/src/box/iproto_features.h>`__
11+
Learn more: :ref:`net.box features <net_box-connect>`, `src/box/iproto_features.h <https://github.com/tarantool/tarantool/blob/master/src/box/iproto_features.h>`__,
1212
and `iproto_features_resolve() <https://github.com/tarantool/tarantool/blob/dec0e0221e183fa972efa65bb0fb658112f2196f/src/box/lua/net_box.lua#L93-L105>`__.
1313

1414
**Example**
Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _reference_lua-box_iproto_send:
1+
.. _reference_lua-box_iproto_send:
22

33
box.iproto.send()
44
=================
@@ -10,17 +10,36 @@ box.iproto.send()
1010
Since version :doc:`2.11.0 </release/2.11.0>`.
1111
Send an :ref:`IPROTO <internals-iproto-format>` packet over the session's socket with the given MsgPack header
1212
and body.
13+
The header and body contain exported IPROTO constants from the :ref:`box.iproto() <box_iproto>` submodule.
14+
Possible IPROTO constant formats:
15+
16+
* lower case constant without the ``IPROTO_`` prefix (``schema_version``, ``request_type``)
17+
* constant from the corresponding :ref:`box.iproto <box_iproto>` subnamespace (``box.iproto.SCHEMA_VERSION``, ``box.iproto.REQUEST_TYPE``)
18+
19+
The function works for binary sessions only. For details, see :ref:`box.session.type() <box_session-type>`.
1320

1421
:param number sid: IPROTO session identifier (see :ref:`box.session.id() <box_session-id>`)
1522
:param table|string header: a request header encoded as MsgPack
1623
:param table|string|nil body: a request body encoded as MsgPack
1724

18-
:return: 0 on success
19-
:return: 1 on error
25+
:return: 0 on success, otherwise an error is raised
2026
:rtype: number
2127

2228
**Possible errors:**
2329

24-
**Example:**
30+
* :errcode:`ER_SESSION_CLOSED` -- the session is closed.
31+
* :errcode:`ER_NO_SUCH_SESSION` -- the session does not exist.
32+
* :errcode:`ER_MEMORY_ISSUE` -- out of memory limit has been reached.
33+
* :errcode:`ER_WRONG_SESSION_TYPE` -- the session type is not binary.
34+
35+
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.
36+
37+
**Example:**
38+
39+
.. code-block:: lua
40+
41+
42+
43+
2544
2645

0 commit comments

Comments
 (0)