| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 1 | Thrift Protocol Structure |
| Nobuaki Sukegawa | 245c347 | 2015-09-21 12:25:10 +0900 | [diff] [blame] | 2 | ==================================================================== |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 3 | |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 4 | Last Modified: 2007-Jun-29 |
| 5 | |
| Jens Geyer | 5767901 | 2016-09-21 22:18:44 +0200 | [diff] [blame] | 6 | <!-- |
| Bryan Duxbury | def30a6 | 2009-04-08 00:19:37 +0000 | [diff] [blame] | 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. |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 25 | |
| 26 | -------------------------------------------------------------------- |
| Jens Geyer | 5767901 | 2016-09-21 22:18:44 +0200 | [diff] [blame] | 27 | --> |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 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 | |
| PoojaChandak | 20205b8 | 2020-11-06 11:33:40 +0100 | [diff] [blame] | 36 | The key point to notice is that ALL messages are just one wrapped |
| Nobuaki Sukegawa | 245c347 | 2015-09-21 12:25:10 +0900 | [diff] [blame] | 37 | `<struct>`. Depending upon the message type, the `<struct>` can be |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 38 | interpreted as the argument list to a function, the return value |
| 39 | of a function, or an exception. |
| 40 | |
| 41 | -------------------------------------------------------------------- |
| 42 | |
| Nobuaki Sukegawa | 245c347 | 2015-09-21 12:25:10 +0900 | [diff] [blame] | 43 | ``` |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 44 | <message> ::= <message-begin> <struct> <message-end> |
| 45 | |
| 46 | <message-begin> ::= <method-name> <message-type> <message-seqid> |
| 47 | |
| 48 | <method-name> ::= STRING |
| 49 | |
| Jens Geyer | a86886e | 2014-09-17 22:25:48 +0200 | [diff] [blame] | 50 | <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION | T_ONEWAY |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 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 |
| Bryan Duxbury | 7003f87 | 2009-02-01 06:21:13 +0000 | [diff] [blame] | 69 | | T_STRING | T_BINARY | T_STRUCT | T_MAP | T_SET | T_LIST |
| Triton Circonflexe | 4959a92 | 2022-06-07 21:40:41 +0200 | [diff] [blame] | 70 | | T_UUID |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 71 | |
| 72 | <field-id> ::= I16 |
| 73 | |
| Bryan Duxbury | 7003f87 | 2009-02-01 06:21:13 +0000 | [diff] [blame] | 74 | <field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING | BINARY |
| Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame] | 75 | <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 Sukegawa | 245c347 | 2015-09-21 12:25:10 +0900 | [diff] [blame] | 102 | ``` |