Skip to content

Commit e2bbee8

Browse files
authored
Add IPROTO_ID request (#2898)
Fixes #2419
1 parent 302f16c commit e2bbee8

File tree

2 files changed

+69
-8
lines changed

2 files changed

+69
-8
lines changed

doc/dev_guide/internals/box_protocol.rst

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The IPROTO constants that identify requests that we will mention in this section
8080
IPROTO_VOTE=0x44
8181
IPROTO_FETCH_SNAPSHOT=0x45
8282
IPROTO_REGISTER=0x46
83+
IPROTO_ID=0x49
8384
8485
The IPROTO constants that appear within requests or responses that we will describe in this section are:
8586

@@ -140,6 +141,8 @@ The IPROTO constants that appear within requests or responses that we will descr
140141
IPROTO_RAFT_VOTE=0x01
141142
IPROTO_RAFT_STATE=0x02
142143
IPROTO_RAFT_VCLOCK=0x03
144+
IPROTO_VERSION=0x54
145+
IPROTO_FEATURES=0x55
143146
144147
145148
To denote message descriptions we will say ``msgpack(...)`` and within it we will use modified
@@ -800,6 +803,53 @@ The body is a 2-item map:
800803
IPROTO_LSN: :samp:`{{MP_INT integer}}`
801804
})
802805
806+
.. _box_protocol-id:
807+
808+
IPROTO_ID = 0x49
809+
~~~~~~~~~~~~~~~~~~~~~~
810+
811+
Clients send this message to inform the server about the protocol version and
812+
features they support. Based on this information, the server can enable or
813+
disable certain features in interacting with these clients.
814+
815+
The body is a 2-item map:
816+
817+
.. cssclass:: highlight
818+
.. parsed-literal::
819+
820+
# <size>
821+
msgpack(:samp:`{{MP_UINT unsigned integer = size(<header>) + size(<body>)}}`)
822+
# <header>
823+
msgpack({
824+
IPROTO_REQUEST_TYPE: IPROTO_ID,
825+
IPROTO_SYNC: :samp:`{{MP_UINT unsigned integer}}`
826+
})
827+
# <body>
828+
msgpack({
829+
IPROTO_VERSION: :samp:`{{MP_UINT unsigned integer}}}`,
830+
IPROTO_FEATURES: :samp:`{{MP_ARRAY array of unsigned integers}}}`
831+
})
832+
833+
IPROTO_VERSION is an integer number reflecting the version of protocol that the
834+
client supports. The latest IPROTO_VERSION is |iproto_version|.
835+
836+
Available IPROTO_FEATURES are the following:
837+
838+
- ``IPROTO_FEATURE_STREAMS = 0`` -- streams support: :ref:`IPROTO_STREAM_ID <box_protocol-iproto_stream_id>`
839+
in the request header.
840+
- ``IPROTO_FEATURE_TRANSACTIONS = 1`` -- transaction support: IPROTO_BEGIN,
841+
IPROTO_COMMIT, and IPROTO_ROLLBACK commands (with :ref:`IPROTO_STREAM_ID <box_protocol-iproto_stream_id>`
842+
in the request header). Learn more about :ref:`sending transaction commands <box_protocol-stream_transactions>`.
843+
- ``IPROTO_FEATURE_ERROR_EXTENSION = 2`` -- :ref:`MP_ERROR <msgpack_ext-error>`
844+
MsgPack extension support. Clients that don't support this feature will receive
845+
error responses for :ref:`IPROTO_EVAL <box_protocol-eval>` and
846+
:ref:`IPROTO_CALL <box_protocol-call>` encoded to string error messages.
847+
- ``IPROTO_FEATURE_WATCHERS = 3`` -- remote watchers support: IPROTO_WATCH,
848+
IPROTO_UNWATCH, and IPROTO_EVENT commands.
849+
.. // TODO: document remote watchers commands
850+
851+
IPROTO_ID requests can be processed without authentication.
852+
803853

804854
.. _box_protocol-responses:
805855

@@ -832,12 +882,20 @@ For IPROTO_OK, the header Response-Code-Indicator will be 0 and the body is a 1-
832882
IPROTO_DATA: :samp:`{{any type}}`
833883
})
834884
835-
For :ref:`IPROTO_PING <box_protocol-ping>` the body will be an empty map.
836-
For most data-access requests (IPROTO_SELECT IPROTO_INSERT IPROTO_DELETE etc.)
837-
the body is an IPROTO_DATA map with an array of tuples that contain an array of fields.
838-
For :ref:`IPROTO_EVAL <box_protocol-eval>` and :ref:`IPROTO_CALL <box_protocol-call>`
839-
it will usually be an array but, since Lua requests can result in a wide variety
840-
of structures, bodies can have a wide variety of structures.
885+
- For :ref:`IPROTO_PING <box_protocol-ping>` the body will be an empty map.
886+
887+
- For most data-access requests (:ref:`IPROTO_SELECT <box_protocol-select>`,
888+
:ref:`IPROTO_INSERT <box_protocol-insert>`, :ref:`IPROTO_DELETE <box_protocol-delete>`
889+
, etc.) the body is an IPROTO_DATA map with an array of tuples that contain
890+
an array of fields.
891+
892+
- For :ref:`IPROTO_EVAL <box_protocol-eval>` and :ref:`IPROTO_CALL <box_protocol-call>`
893+
it will usually be an array but, since Lua requests can result in a wide variety
894+
of structures, bodies can have a wide variety of structures.
895+
896+
- For :ref:`IPROTO_ID <box_protocol-id>`, the response body has the same structure as
897+
the request body. It informs the client about the protocol version and features
898+
that the server supports.
841899

842900
Example: if this is the fifth message and the request is
843901
:codenormal:`box.space.`:codeitalic:`space-name`:codenormal:`:insert{6}`,
@@ -1171,9 +1229,8 @@ function ``netbox_encode_auth``.
11711229

11721230
.. _box_protocol-streams:
11731231

1174-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11751232
Binary protocol -- streams
1176-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1233+
--------------------------
11771234

11781235
The :ref:`Streams and interactive transactions <box_stream>`
11791236
feature, which was added in Tarantool version
@@ -1221,6 +1278,8 @@ that the header will contain an additional item: IPROTO_STREAM_ID=0x0a
12211278
with MP_UINT=0x01. It happens to equal 1 for this example because
12221279
each call to conn:new_stream() assigns a new number, starting with 1.
12231280

1281+
.. _box_protocol-stream_transactions:
1282+
12241283
The client makes stream transactions by sending, in order:
12251284
IPROTO_BEGIN, the transaction data-change and query requests,
12261285
IPROTO_COMMIT or IPROTO_ROLLBACK.

prolog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@
3434

3535
<br />
3636

37+
.. |iproto_version| replace:: 3
38+

0 commit comments

Comments
 (0)