blob: 60e757d746aa77d5c8b77ffc0428a3197147a52e [file] [log] [blame]
Mark Slee477a5802007-06-30 01:18:12 +00001Thrift Protocol Structure
2
3Mark Slee (mcslee@facebook.com)
4
5Last Modified: 2007-Jun-29
6
7Thrift is distributed under the Thrift open source software license.
8Please see the included LICENSE file.
9
10--------------------------------------------------------------------
11
12This document describes the structure of the Thrift protocol
13without specifying the encoding. Thus, the order of elements
14could in some cases be rearranged depending upon the TProtocol
15implementation, but this document specifies the minimum required
16structure. There are some "dumb" terminals like STRING and INT
17that take the place of an actual encoding specification.
18
19They key point to notice is that ALL messages are just one wrapped
20<struct>. Depending upon the message type, the <struct> can be
21interpreted as the argument list to a function, the return value
22of a function, or an exception.
23
24--------------------------------------------------------------------
25
26 <message> ::= <message-begin> <struct> <message-end>
27
28 <message-begin> ::= <method-name> <message-type> <message-seqid>
29
30 <method-name> ::= STRING
31
32 <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION
33
34 <message-seqid> ::= I32
35
36 <struct> ::= <struct-begin> <field>* <field-stop> <struct-end>
37
38 <struct-begin> ::= <struct-name>
39
40 <struct-name> ::= STRING
41
42 <field-stop> ::= T_STOP
43
44 <field> ::= <field-begin> <field-data> <field-end>
45
46 <field-begin> ::= <field-name> <field-type> <field-id>
47
48 <field-name> ::= STRING
49
50 <field-type> ::= T_BOOL | T_BYTE | T_I8 | T_I16 | T_I32 | T_I64 | T_DOUBLE
51 | T_STRING | T_STRUCT | T_MAP | T_SET | T_LIST
52
53 <field-id> ::= I16
54
55 <field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING |
56 <struct> | <map> | <list> | <set>
57
58 <map> ::= <map-begin> <field-datum>* <map-end>
59
60 <map-begin> ::= <map-key-type> <map-value-type> <map-size>
61
62 <map-key-type> ::= <field-type>
63
64<map-value-type> ::= <field-type>
65
66 <map-size> ::= I32
67
68 <list> ::= <list-begin> <field-data>* <list-end>
69
70 <list-begin> ::= <list-elem-type> <list-size>
71
72<list-elem-type> ::= <field-type>
73
74 <list-size> ::= I32
75
76 <set> ::= <set-begin> <field-data>* <set-end>
77
78 <set-begin> ::= <set-elem-type> <set-size>
79
80 <set-elem-type> ::= <field-type>
81
82 <set-size> ::= I32