1 Thrift Protocol Structure
3 Mark Slee
(mcslee@facebook
.com
)
5 Last Modified
: 2007-Jun-
29
7 Thrift is distributed under the Thrift open source software license
.
8 Please see the included LICENSE file
.
10 --------------------------------------------------------------------
12 This document describes the structure of the Thrift protocol
13 without specifying the encoding
. Thus, the order of elements
14 could in some cases be rearranged depending upon the TProtocol
15 implementation, but this document specifies the minimum required
16 structure
. There are some
"dumb" terminals like STRING and INT
17 that take the place of an actual encoding specification
.
19 They key point to notice is that ALL messages are just one wrapped
20 <struct>
. Depending upon the message type, the <struct> can be
21 interpreted as the argument list to a function, the return value
22 of a function, or an exception
.
24 --------------------------------------------------------------------
26 <message> ::= <message-begin> <struct> <message-end>
28 <message-begin> ::= <method-name> <message-type> <message-seqid>
30 <method-name> ::= STRING
32 <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION
34 <message-seqid> ::= I
32
36 <struct> ::= <struct-begin> <field>* <field-stop> <struct-end>
38 <struct-begin> ::= <struct-name>
40 <struct-name> ::= STRING
42 <field-stop> ::= T_STOP
44 <field> ::= <field-begin> <field-data> <field-end>
46 <field-begin> ::= <field-name> <field-type> <field-id>
48 <field-name> ::= STRING
50 <field-type> ::= T_BOOL | T_BYTE | T_I
8 | T_I
16 | T_I
32 | T_I
64 | T_DOUBLE
51 | T_STRING | T_STRUCT | T_MAP | T_SET | T_LIST
55 <field-data> ::= I
8 | I
16 | I
32 | I
64 | DOUBLE | STRING |
56 <struct> | <map> | <list> | <set>
58 <map> ::= <map-begin> <field-datum>* <map-end>
60 <map-begin> ::= <map-key-type> <map-value-type> <map-size>
62 <map-key-type> ::= <field-type>
64 <map-value-type> ::= <field-type>
68 <list> ::= <list-begin> <field-data>* <list-end>
70 <list-begin> ::= <list-elem-type> <list-size>
72 <list-elem-type> ::= <field-type>
76 <set> ::= <set-begin> <field-data>* <set-end>
78 <set-begin> ::= <set-elem-type> <set-size>
80 <set-elem-type> ::= <field-type>