blob: d66b7ebafff5df70c831def8c8c29a70384f6ae4 [file] [log] [blame]
Marc Slemko03eafbe2006-08-02 20:01:22 +00001This is the BNF for the Thrift wire protocol. Wire-protocol encoder/decoders must provide methods to encode/decode all the terminals in this BNF. The BNF is designed to allow for both binary and ascii encodings, including XML encodings. The latter requirement necessitates breaking all logical message components into header and body as well as delimiting beginning and end of each component. In this was it is possible to represent a component as a start tag (component bebug) with attributes (component-header) some arbitray number of child elements, and end tag (component end).
2
3For binary formats it is typically not necessary to represent the begin and end of component on the wire. The only time the driver expects variable input is for field lists. Field lists are terminated with the special STOP field. Thus, the driver always knows what component to expect next. Thus binary formats can dispence with component start and end delimiters.
4
5""" General message format """
6
7 message-stream : message-stream message | NIL
8 message : MSG_b message-header message-body MSG_e
9 message-header : MSGH_b protocol-version sequence-number message-type MSGH_e
10 protocol-version : protocol-version-major protocol-version-minor
11 protocol-version-major : UINT08
12 protocol-version-minor : UINT08
13 sequence-number : UINT32
14 message-type : INVOKE | REPLY
15
16 message-body : invoke-body | reply-body
17
18""" service function invoke message body """
19
20 invoke-body : function-specifier arguments
21
22 function-specifier : service-qname function-name
23 service-qname : package-name service-name
24 function-name : STRING
25 package-name : STRING
26 service-name : STRING
27
Marc Slemko16698852006-08-04 03:16:10 +000028 arguments : struct-datum
Marc Slemko03eafbe2006-08-02 20:01:22 +000029
30""" service function reply message body """
31
32 reply-body : in-reply-to-id result
33
34 result : RES_b result-header result-body RES_e
35
36 result-header : RESH_b result-type RESH_e
37
38 result-type : RES_NORMAL | RES_ERROR | RES_IOERROR
39
40 result-body : normal-result-body | error-result-body
41
42 normal-result-body : RESB_b datum RESB_e
43
44 error-result-body : RESB_b datum RESB_e // error datum is constrained to be derived from some exception type
45
46""" wire representation of simple, collection and composite data """
47
48 datum : DATUM_b datum-header datum-body DATUM_e
49 datum-header : DATUMH_b type-specifier datum-identifier DATUMH_e
50 type-specifier : simple-type-specifier | complex-type-specifier
51
52 datum-identifier : datum-qname | datum-id | datum-name datum-id
53
54 datum-qname : package-name datum-name
55 datum-name : STRING
56 datum-id : UINT32
57 datum-body : DATUMB_b simple-datum | collection-datum | struct-datum DATUMB_e
58
59""" simple datum """
60
61 simple-type-specifier : I08 | I16 | I32 | I64 | U08 | U16 | U32 | U64 | STRING | UTF8 | UTF16 | FLOAT | BOOL | STOP
62
63 simple-data : simple-data simple-datum | NIL
64
65 simple-datum : bool-datum |
66 i08-datum | i16-datum | i32-datum | i64-datum |
67 u08-datum | u16b-datum | u32-datum | u64-datum |
68 string-datum | utf7-datum | utf8-datum | utf16-datum // string and utf7 are equivalent
69
70""" Complex data """
71
72 complex-type-specifier collection-type-specifier | struct-type-specifier
73
74""" collection datum """
75
Marc Slemko16698852006-08-04 03:16:10 +000076 collection-type-specifier : MAP | SET | LIST
Marc Slemko03eafbe2006-08-02 20:01:22 +000077
78 collection-datum : list-datum | set-datum | map-datum
79
Marc Slemko03eafbe2006-08-02 20:01:22 +000080 list-datum : LIST_b element-count element-type-specifier elements LIST_e
81
82 element-count : UINT32
83
84 element-type-specifier : type-specifier
85
86 elements : elements element | NIL
87
88 element : datum
89
90 set-datum : SET_b element-count element-type-specifier elements SET_e
91
92 map-datum : MAP_b element-count map-key-type-specifier map-value-type-specifier map-pairs MAP_e
93
94 map-key-type-specifier : type-specifier
95
96 map-value-type-specifier : type-specifier
97
98 map-pairs : map-pairs map-pair | NIL
99
100 map-pair : MAPP_b key-datum value-datum MAPP_e
101
102""" struct datum """
103
104 struct-type-specifier : STRUCT
105
106 struct-datum : STRUCT_b field-list STRUCT_e
107
108 field-list : fields terminal-field
109
110 fields : fields field | NIL
111
112 field : datum
113
114 terminal-field : datum // Datum type is STOP
115
116
117