]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | Thrift Protocol Structure |
2 | ==================================================================== | |
3 | ||
4 | Last Modified: 2007-Jun-29 | |
5 | ||
6 | <!-- | |
7 | -------------------------------------------------------------------- | |
8 | ||
9 | Licensed to the Apache Software Foundation (ASF) under one | |
10 | or more contributor license agreements. See the NOTICE file | |
11 | distributed with this work for additional information | |
12 | regarding copyright ownership. The ASF licenses this file | |
13 | to you under the Apache License, Version 2.0 (the | |
14 | "License"); you may not use this file except in compliance | |
15 | with the License. You may obtain a copy of the License at | |
16 | ||
17 | http://www.apache.org/licenses/LICENSE-2.0 | |
18 | ||
19 | Unless required by applicable law or agreed to in writing, | |
20 | software distributed under the License is distributed on an | |
21 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
22 | KIND, either express or implied. See the License for the | |
23 | specific language governing permissions and limitations | |
24 | under the License. | |
25 | ||
26 | -------------------------------------------------------------------- | |
27 | --> | |
28 | ||
29 | This document describes the structure of the Thrift protocol | |
30 | without specifying the encoding. Thus, the order of elements | |
31 | could in some cases be rearranged depending upon the TProtocol | |
32 | implementation, but this document specifies the minimum required | |
33 | structure. There are some "dumb" terminals like STRING and INT | |
34 | that take the place of an actual encoding specification. | |
35 | ||
36 | They key point to notice is that ALL messages are just one wrapped | |
37 | `<struct>`. Depending upon the message type, the `<struct>` can be | |
38 | interpreted as the argument list to a function, the return value | |
39 | of a function, or an exception. | |
40 | ||
41 | -------------------------------------------------------------------- | |
42 | ||
43 | ``` | |
44 | <message> ::= <message-begin> <struct> <message-end> | |
45 | ||
46 | <message-begin> ::= <method-name> <message-type> <message-seqid> | |
47 | ||
48 | <method-name> ::= STRING | |
49 | ||
50 | <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION | T_ONEWAY | |
51 | ||
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 | |
69 | | T_STRING | T_BINARY | T_STRUCT | T_MAP | T_SET | T_LIST | |
70 | ||
71 | <field-id> ::= I16 | |
72 | ||
73 | <field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING | BINARY | |
74 | <struct> | <map> | <list> | <set> | |
75 | ||
76 | <map> ::= <map-begin> <field-datum>* <map-end> | |
77 | ||
78 | <map-begin> ::= <map-key-type> <map-value-type> <map-size> | |
79 | ||
80 | <map-key-type> ::= <field-type> | |
81 | ||
82 | <map-value-type> ::= <field-type> | |
83 | ||
84 | <map-size> ::= I32 | |
85 | ||
86 | <list> ::= <list-begin> <field-data>* <list-end> | |
87 | ||
88 | <list-begin> ::= <list-elem-type> <list-size> | |
89 | ||
90 | <list-elem-type> ::= <field-type> | |
91 | ||
92 | <list-size> ::= I32 | |
93 | ||
94 | <set> ::= <set-begin> <field-data>* <set-end> | |
95 | ||
96 | <set-begin> ::= <set-elem-type> <set-size> | |
97 | ||
98 | <set-elem-type> ::= <field-type> | |
99 | ||
100 | <set-size> ::= I32 | |
101 | ``` |