blob: 4b0efafee2c4aae83b8605bb08ced1c8b06dd533 [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
Jens Geyer57679012016-09-21 22:18:44 +02006<!--
Bryan Duxburydef30a62009-04-08 00:19:37 +00007--------------------------------------------------------------------
8
9Licensed to the Apache Software Foundation (ASF) under one
10or more contributor license agreements. See the NOTICE file
11distributed with this work for additional information
12regarding copyright ownership. The ASF licenses this file
13to you under the Apache License, Version 2.0 (the
14"License"); you may not use this file except in compliance
15with the License. You may obtain a copy of the License at
16
17 http://www.apache.org/licenses/LICENSE-2.0
18
19Unless required by applicable law or agreed to in writing,
20software distributed under the License is distributed on an
21"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22KIND, either express or implied. See the License for the
23specific language governing permissions and limitations
24under the License.
Mark Slee477a5802007-06-30 01:18:12 +000025
26--------------------------------------------------------------------
Jens Geyer57679012016-09-21 22:18:44 +020027-->
Mark Slee477a5802007-06-30 01:18:12 +000028
29This document describes the structure of the Thrift protocol
30without specifying the encoding. Thus, the order of elements
31could in some cases be rearranged depending upon the TProtocol
32implementation, but this document specifies the minimum required
33structure. There are some "dumb" terminals like STRING and INT
34that take the place of an actual encoding specification.
35
PoojaChandak20205b82020-11-06 11:33:40 +010036The key point to notice is that ALL messages are just one wrapped
Nobuaki Sukegawa245c3472015-09-21 12:25:10 +090037`<struct>`. Depending upon the message type, the `<struct>` can be
Mark Slee477a5802007-06-30 01:18:12 +000038interpreted as the argument list to a function, the return value
39of a function, or an exception.
40
41--------------------------------------------------------------------
42
Nobuaki Sukegawa245c3472015-09-21 12:25:10 +090043```
Mark Slee477a5802007-06-30 01:18:12 +000044 <message> ::= <message-begin> <struct> <message-end>
45
46 <message-begin> ::= <method-name> <message-type> <message-seqid>
47
48 <method-name> ::= STRING
49
Jens Geyera86886e2014-09-17 22:25:48 +020050 <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION | T_ONEWAY
Mark Slee477a5802007-06-30 01:18:12 +000051
52 <message-seqid> ::= I32
53
54 <struct> ::= <struct-begin> <field>* <field-stop> <struct-end>
55
56 <struct-begin> ::= <struct-name>
57
58 <struct-name> ::= STRING
59
60 <field-stop> ::= T_STOP
61
62 <field> ::= <field-begin> <field-data> <field-end>
63
64 <field-begin> ::= <field-name> <field-type> <field-id>
65
66 <field-name> ::= STRING
67
68 <field-type> ::= T_BOOL | T_BYTE | T_I8 | T_I16 | T_I32 | T_I64 | T_DOUBLE
Bryan Duxbury7003f872009-02-01 06:21:13 +000069 | T_STRING | T_BINARY | T_STRUCT | T_MAP | T_SET | T_LIST
Triton Circonflexe4959a922022-06-07 21:40:41 +020070 | T_UUID
Mark Slee477a5802007-06-30 01:18:12 +000071
72 <field-id> ::= I16
73
Bryan Duxbury7003f872009-02-01 06:21:13 +000074 <field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING | BINARY
Mark Slee477a5802007-06-30 01:18:12 +000075 <struct> | <map> | <list> | <set>
76
77 <map> ::= <map-begin> <field-datum>* <map-end>
78
79 <map-begin> ::= <map-key-type> <map-value-type> <map-size>
80
81 <map-key-type> ::= <field-type>
82
83<map-value-type> ::= <field-type>
84
85 <map-size> ::= I32
86
87 <list> ::= <list-begin> <field-data>* <list-end>
88
89 <list-begin> ::= <list-elem-type> <list-size>
90
91<list-elem-type> ::= <field-type>
92
93 <list-size> ::= I32
94
95 <set> ::= <set-begin> <field-data>* <set-end>
96
97 <set-begin> ::= <set-elem-type> <set-size>
98
99 <set-elem-type> ::= <field-type>
100
101 <set-size> ::= I32
Nobuaki Sukegawa245c3472015-09-21 12:25:10 +0900102```