Skip to content

Commit 10f5b61

Browse files
committed
Minor additions
1 parent 3c9b551 commit 10f5b61

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

doc/dev_guide/reference_capi/box.rst

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,15 @@
284284
Sets an IPROTO request handler with the provided context for the given request type.
285285
The function yields.
286286
287-
Possible values:
287+
:param uint32_t request_type: request type code from the ``iproto_type`` enumeration
288+
:param iproto_handler_t handler: IPROTO request handler. To reset the request handler, set the ``handler`` parameter to ``NULL``.
288289
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.
290+
See the full parameter description in the :ref:`Handler function <box_box_iproto_override-handler>` section.
291291
292-
* ``box.iproto.type.UNKNOWN`` -- override an unknown request type.
292+
:param iproto_handler_destroy_t destroy: IPROTO request handler destructor. The destructor is called when the
293+
corresponding handler is removed. See the full parameter description
294+
in the :ref:`Handler destructor function <box_box_iproto_override-destroy>` section.
293295
294-
:param uint32_t request_type: request type code from the ``iproto_type`` enumeration
295-
:param iproto_handler_t handler: IPROTO request handler. To reset the request handler, set the ``handler`` parameter to ``NULL``.
296-
:param iproto_handler_destroy_t destroy: IPROTO request handler destructor
297296
:param void* ctx: a context passed to the ``handler`` and ``destroy`` callbacks
298297
299298
:return: 0 on success
@@ -307,4 +306,49 @@
307306
* :errcode:`ER_PROC_LUA` -- the exception is thrown, diagnostic is not set.
308307
* diagnostics from ``src/box/errcode.h`` -- the exception is thrown, diagnostic is set.
309308
310-
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.
309+
For details, see `src/box/errcode.h <https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h>`__.
310+
311+
.. _box_box_iproto_override-handler:
312+
313+
**Handler function**
314+
315+
The signature of a handler function (the ``handler`` parameter):
316+
317+
.. code-block:: c
318+
319+
enum iproto_handler_status {
320+
IPROTO_HANDLER_OK,
321+
IPROTO_HANDLER_ERROR,
322+
IPROTO_HANDLER_FALLBACK,
323+
}
324+
325+
typedef enum iproto_handler_status
326+
(*iproto_handler_t)(const char *header, const char *header_end,
327+
const char *body, const char *body_end, void *ctx);
328+
329+
where:
330+
331+
* ``header``(const char*) -- a MsgPack-encoded header
332+
* ``header_end``(const char*) -- end of a header encoded as MsgPack
333+
* ``body``(const char*) -- a MsgPack-encoded body
334+
* ``header_end``(const char*) -- end of a body encoded as MsgPack
335+
336+
The handler returns a status code. Possible statuses:
337+
338+
* ``IPROTO_REQUEST_HANDLER_OK`` -- success
339+
* ``IPROTO_REQUEST_HANDLER_ERROR`` -- error, diagnostic must be set by handler
340+
* ``IPROTO_REQUEST_HANDLER_FALLBACK`` -- fallback to the system handler
341+
342+
.. _box_box_iproto_override-destroy:
343+
344+
**Handler destructor function**
345+
346+
The signature of a destructor function (the ``destroy`` parameter):
347+
348+
.. code-block:: c
349+
350+
typedef void (*iproto_handler_destroy_t)(void *ctx);
351+
352+
where:
353+
354+
* ``ctx`` (void*): the context provided by ``box_iproto_override()`` function.

doc/reference/reference_lua/box_iproto.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The table lists all available functions and data of the submodule:
108108
* - Name
109109
- Use
110110

111-
* - :doc:`./box_iproto/keys`
111+
* - :doc:`./box_iproto/key`
112112
- Request keys
113113

114114
* - :doc:`./box_iproto/request_type`

0 commit comments

Comments
 (0)