Skip to content

Commit 920c973

Browse files
committed
Add raft-related constants in tables and initial iproto_raft request description
Part of #2814
1 parent 172d7cb commit 920c973

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

doc/dev_guide/internals/box_protocol.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ The IPROTO constants that identify requests that we will mention in this section
7070
IPROTO_ROLLBACK=0x10
7171
IPROTO_RAFT_CONFIRM=0x28
7272
IPROTO_RAFT_ROLLBACK=0x29
73+
IPROTO_RAFT=0x1e
74+
IPROTO_RAFT_PROMOTE=0x1f
75+
IPROTO_RAFT_DEMOTE=0x20
7376
IPROTO_PING=0x40
7477
IPROTO_JOIN=0x41
7578
IPROTO_SUBSCRIBE=0x42
@@ -132,6 +135,10 @@ The IPROTO constants that appear within requests or responses that we will descr
132135
IPROTO_FIELD_IS_NULLABLE=0x03
133136
IPROTO_FIELD_IS_AUTOINCREMENT=0x04
134137
IPROTO_FIELD_SPAN=0x05
138+
IPROTO_RAFT_TERM=0x00
139+
IPROTO_RAFT_VOTE=0x01
140+
IPROTO_RAFT_STATE=0x02
141+
IPROTO_RAFT_VCLOCK=0x03
135142
136143
To denote message descriptions we will say ``msgpack(...)`` and within it we will use modified
137144
`YAML <https://en.wikipedia.org/wiki/YAML>`_ so: |br|
@@ -1406,6 +1413,46 @@ IPROTO_FLAG_COMMIT (0x01) will be set if this is the last message for a transact
14061413
IPROTO_FLAG_WAIT_SYNC (0x02) will be set if this is the last message for a transaction which cannot be completed immediately,
14071414
IPROTO_FLAG_WAIT_ACK (0x04) will be set if this is the last message for a synchronous transaction.
14081415

1416+
.. _box_protocol-raft:
1417+
1418+
IPROTO_RAFT = 0x1e
1419+
~~~~~~~~~~~~~~~~~~
1420+
1421+
[TBD] intro
1422+
1423+
IPROTO_RAFT рассылается броадкастами всем подключённым к ноде репликам.
1424+
Если подразумевается какой-то ответ на запрос (например, когда это запрос другим нодам на голосование),
1425+
то нужно, чтобы нода сама была подключена репликой к серверу, от которого ждёт ответ, потому что он придёт по каналу репликации.
1426+
1427+
Другими словами, связь между всеми должна быть в обе стороны (фуллмеш)
1428+
1429+
1430+
[TBD] update request structure
1431+
1432+
.. cssclass:: highlight
1433+
.. parsed-literal::
1434+
1435+
# <size>
1436+
msgpack(:samp:`{{MP_UINT unsigned integer = size(<header>) + size(<body>)}}`)
1437+
# <header>
1438+
msgpack({
1439+
IPROTO_REQUEST_TYPE: IPROTO_RAFT,
1440+
IPROTO_SYNC: :samp:`{{MP_UINT unsigned integer}}`,
1441+
IPROTO_INSTANCE_UUID: :samp:`{{uuid}}`,
1442+
IPROTO_CLUSTER_UUID: :samp:`{{uuid}}`,
1443+
})
1444+
# <body>
1445+
msgpack({
1446+
IPROTO_RAFT_TERM=0x00
1447+
IPROTO_RAFT_VOTE=0x01
1448+
IPROTO_RAFT_STATE=0x02
1449+
IPROTO_RAFT_VCLOCK=0x03
1450+
})
1451+
1452+
[TBD] update about response
1453+
1454+
Это асинхронный протокол, и response там - другое сообщение IPROTO_RAFT, а бывает вообще без response
1455+
14091456
.. _box_protocol-illustration:
14101457

14111458
Examples

0 commit comments

Comments
 (0)