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