blob: 950e1633572c9b37efe4d0cdb08505e3d0699dea [file] [log] [blame] [view]
Mark Slee477a5802007-06-30 01:18:12 +00001Thrift Protocol Structure
Nobuaki Sukegawa245c3472015-09-21 12:25:10 +09002====================================================================
Mark Slee477a5802007-06-30 01:18:12 +00003
Mark Slee477a5802007-06-30 01:18:12 +00004Last Modified: 2007-Jun-29
5
Bryan Duxburydef30a62009-04-08 00:19:37 +00006--------------------------------------------------------------------
7
8Licensed to the Apache Software Foundation (ASF) under one
9or more contributor license agreements. See the NOTICE file
10distributed with this work for additional information
11regarding copyright ownership. The ASF licenses this file
12to you under the Apache License, Version 2.0 (the
13"License"); you may not use this file except in compliance
14with the License. You may obtain a copy of the License at
15
16 http://www.apache.org/licenses/LICENSE-2.0
17
18Unless required by applicable law or agreed to in writing,
19software distributed under the License is distributed on an
20"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21KIND, either express or implied. See the License for the
22specific language governing permissions and limitations
23under the License.
Mark Slee477a5802007-06-30 01:18:12 +000024
25--------------------------------------------------------------------
26
27This document describes the structure of the Thrift protocol
28without specifying the encoding. Thus, the order of elements
29could in some cases be rearranged depending upon the TProtocol
30implementation, but this document specifies the minimum required
31structure. There are some "dumb" terminals like STRING and INT
32that take the place of an actual encoding specification.
33
34They key point to notice is that ALL messages are just one wrapped
Nobuaki Sukegawa245c3472015-09-21 12:25:10 +090035`<struct>`. Depending upon the message type, the `<struct>` can be
Mark Slee477a5802007-06-30 01:18:12 +000036interpreted as the argument list to a function, the return value
37of a function, or an exception.
38
39--------------------------------------------------------------------
40
Nobuaki Sukegawa245c3472015-09-21 12:25:10 +090041```
Mark Slee477a5802007-06-30 01:18:12 +000042 <message> ::= <message-begin> <struct> <message-end>
43
44 <message-begin> ::= <method-name> <message-type> <message-seqid>
45
46 <method-name> ::= STRING
47
Jens Geyera86886e2014-09-17 22:25:48 +020048 <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION | T_ONEWAY
Mark Slee477a5802007-06-30 01:18:12 +000049
50 <message-seqid> ::= I32
51
52 <struct> ::= <struct-begin> <field>* <field-stop> <struct-end>
53
54 <struct-begin> ::= <struct-name>
55
56 <struct-name> ::= STRING
57
58 <field-stop> ::= T_STOP
59
60 <field> ::= <field-begin> <field-data> <field-end>
61
62 <field-begin> ::= <field-name> <field-type> <field-id>
63
64 <field-name> ::= STRING
65
66 <field-type> ::= T_BOOL | T_BYTE | T_I8 | T_I16 | T_I32 | T_I64 | T_DOUBLE
Bryan Duxbury7003f872009-02-01 06:21:13 +000067 | T_STRING | T_BINARY | T_STRUCT | T_MAP | T_SET | T_LIST
Mark Slee477a5802007-06-30 01:18:12 +000068
69 <field-id> ::= I16
70
Bryan Duxbury7003f872009-02-01 06:21:13 +000071 <field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING | BINARY
Mark Slee477a5802007-06-30 01:18:12 +000072 <struct> | <map> | <list> | <set>
73
74 <map> ::= <map-begin> <field-datum>* <map-end>
75
76 <map-begin> ::= <map-key-type> <map-value-type> <map-size>
77
78 <map-key-type> ::= <field-type>
79
80<map-value-type> ::= <field-type>
81
82 <map-size> ::= I32
83
84 <list> ::= <list-begin> <field-data>* <list-end>
85
86 <list-begin> ::= <list-elem-type> <list-size>
87
88<list-elem-type> ::= <field-type>
89
90 <list-size> ::= I32
91
92 <set> ::= <set-begin> <field-data>* <set-end>
93
94 <set-begin> ::= <set-elem-type> <set-size>
95
96 <set-elem-type> ::= <field-type>
97
98 <set-size> ::= I32
Nobuaki Sukegawa245c3472015-09-21 12:25:10 +090099```