| 30 |
ashish |
1 |
Thrift Protocol Structure
|
|
|
2 |
|
|
|
3 |
Last Modified: 2007-Jun-29
|
|
|
4 |
|
|
|
5 |
--------------------------------------------------------------------
|
|
|
6 |
|
|
|
7 |
Licensed to the Apache Software Foundation (ASF) under one
|
|
|
8 |
or more contributor license agreements. See the NOTICE file
|
|
|
9 |
distributed with this work for additional information
|
|
|
10 |
regarding copyright ownership. The ASF licenses this file
|
|
|
11 |
to you under the Apache License, Version 2.0 (the
|
|
|
12 |
"License"); you may not use this file except in compliance
|
|
|
13 |
with the License. You may obtain a copy of the License at
|
|
|
14 |
|
|
|
15 |
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
16 |
|
|
|
17 |
Unless required by applicable law or agreed to in writing,
|
|
|
18 |
software distributed under the License is distributed on an
|
|
|
19 |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
20 |
KIND, either express or implied. See the License for the
|
|
|
21 |
specific language governing permissions and limitations
|
|
|
22 |
under the License.
|
|
|
23 |
|
|
|
24 |
--------------------------------------------------------------------
|
|
|
25 |
|
|
|
26 |
This document describes the structure of the Thrift protocol
|
|
|
27 |
without specifying the encoding. Thus, the order of elements
|
|
|
28 |
could in some cases be rearranged depending upon the TProtocol
|
|
|
29 |
implementation, but this document specifies the minimum required
|
|
|
30 |
structure. There are some "dumb" terminals like STRING and INT
|
|
|
31 |
that take the place of an actual encoding specification.
|
|
|
32 |
|
|
|
33 |
They key point to notice is that ALL messages are just one wrapped
|
|
|
34 |
<struct>. Depending upon the message type, the <struct> can be
|
|
|
35 |
interpreted as the argument list to a function, the return value
|
|
|
36 |
of 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
|
|
|
65 |
| T_STRING | T_BINARY | T_STRUCT | T_MAP | T_SET | T_LIST
|
|
|
66 |
|
|
|
67 |
<field-id> ::= I16
|
|
|
68 |
|
|
|
69 |
<field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING | BINARY
|
|
|
70 |
<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
|