|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
| 5 | +<link href="style.css" rel="stylesheet" type="text/css"/> |
| 6 | +<title>Thrift module: message</title></head><body> |
| 7 | +<div class="container-fluid"> |
| 8 | +<h1>Thrift module: message</h1> |
| 9 | +<table class="table-bordered table-striped table-condensed"><thead><tr><th>Module</th><th>Services</th><th>Data types</th><th>Constants</th></tr></thead><tbody> |
| 10 | +<tr> |
| 11 | +<td>message</td><td><a href="#Svc_Calculator">Calculator</a><br/> |
| 12 | +<ul> |
| 13 | +<li><a href="#Fn_Calculator_add">add</a></li> |
| 14 | +<li><a href="#Fn_Calculator_calculate">calculate</a></li> |
| 15 | +<li><a href="#Fn_Calculator_ping">ping</a></li> |
| 16 | +<li><a href="#Fn_Calculator_zip">zip</a></li> |
| 17 | +</ul> |
| 18 | +</td> |
| 19 | +<td><a href="#Struct_InvalidOperation">InvalidOperation</a><br/> |
| 20 | +<a href="#Enum_Operation">Operation</a><br/> |
| 21 | +<a href="#Struct_Work">Work</a><br/> |
| 22 | +</td> |
| 23 | +<td><code><a href="#Const_INT32CONSTANT">INT32CONSTANT</a></code><br/> |
| 24 | +<code><a href="#Const_MAPCONSTANT">MAPCONSTANT</a></code><br/> |
| 25 | +</td> |
| 26 | +</tr></tbody></table> |
| 27 | +<hr/><h2 id="Constants">Constants</h2> |
| 28 | +<table class="table-bordered table-striped table-condensed"><thead><tr><th>Constant</th><th>Type</th><th>Value</th></tr></thead><tbody> |
| 29 | +<tr id="Const_INT32CONSTANT"><td><code>INT32CONSTANT</code></td><td><code>i32</code></td><td><code>9853</code></td></tr><tr><td colspan="3"><blockquote><pre>Thrift also lets you define constants for use across languages. Complex |
| 30 | +types and structs are specified using JSON notation. |
| 31 | +</pre><br/></blockquote></td></tr><tr id="Const_MAPCONSTANT"><td><code>MAPCONSTANT</code></td><td><code>map<<code>string</code>, <code>string</code>></code></td><td><code>{ "goodnight" = "moon", "hello" = "world" }</code></td></tr></tbody></table><hr/><h2 id="Enumerations">Enumerations</h2> |
| 32 | +<div class="definition"><h3 id="Enum_Operation">Enumeration: Operation</h3> |
| 33 | +<pre>You can define enums, which are just 32 bit integers. Values are optional |
| 34 | +and start at 1 if not supplied, C style again. |
| 35 | +</pre><br/><br/><table class="table-bordered table-striped table-condensed"> |
| 36 | +<tr><td><code>ADD</code></td><td><code>1</code></td><td> |
| 37 | +</td></tr> |
| 38 | +<tr><td><code>SUBTRACT</code></td><td><code>2</code></td><td> |
| 39 | +</td></tr> |
| 40 | +<tr><td><code>MULTIPLY</code></td><td><code>3</code></td><td> |
| 41 | +</td></tr> |
| 42 | +<tr><td><code>DIVIDE</code></td><td><code>4</code></td><td> |
| 43 | +</td></tr> |
| 44 | +</table></div> |
| 45 | +<hr/><h2 id="Structs">Data structures</h2> |
| 46 | +<div class="definition"><h3 id="Struct_Work">Struct: Work</h3> |
| 47 | +<table class="table-bordered table-striped table-condensed"><thead><tr><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</th><th>Default value</th></tr></thead><tbody> |
| 48 | +<tr><td>1</td><td>num1</td><td><code>i32</code></td><td></td><td>default</td><td><code>0</code></td></tr> |
| 49 | +<tr><td>2</td><td>num2</td><td><code>i32</code></td><td></td><td>default</td><td></td></tr> |
| 50 | +<tr><td>3</td><td>op</td><td><code><a href="#Enum_Operation">Operation</a></code></td><td></td><td>default</td><td></td></tr> |
| 51 | +<tr><td>4</td><td>comment</td><td><code>string</code></td><td></td><td>optional</td><td></td></tr> |
| 52 | +</tbody></table><br/><pre>Structs are the basic complex data structures. They are comprised of fields |
| 53 | +which each have an integer identifier, a type, a symbolic name, and an |
| 54 | +optional default value. |
| 55 | + |
| 56 | +Fields can be declared "optional", which ensures they will not be included |
| 57 | +in the serialized output if they aren't set. Note that this requires some |
| 58 | +manual management in some languages. |
| 59 | +</pre><br/></div><div class="definition"><h3 id="Struct_InvalidOperation">Exception: InvalidOperation</h3> |
| 60 | +<table class="table-bordered table-striped table-condensed"><thead><tr><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</th><th>Default value</th></tr></thead><tbody> |
| 61 | +<tr><td>1</td><td>what</td><td><code>i32</code></td><td></td><td>default</td><td></td></tr> |
| 62 | +<tr><td>2</td><td>why</td><td><code>string</code></td><td></td><td>default</td><td></td></tr> |
| 63 | +</tbody></table><br/><pre>Structs can also be exceptions, if they are nasty. |
| 64 | +</pre><br/></div><hr/><h2 id="Services">Services</h2> |
| 65 | +<h3 id="Svc_Calculator">Service: Calculator</h3> |
| 66 | +<pre>Ahh, now onto the cool part, defining a service. Services just need a name |
| 67 | +and can optionally inherit from another service using the extends keyword. |
| 68 | +</pre><br/><div class="definition"><h4 id="Fn_Calculator_ping">Function: Calculator.ping</h4> |
| 69 | +<pre><code>void</code> ping() |
| 70 | +</pre><pre>A method definition looks like C code. It has a return type, arguments, |
| 71 | +and optionally a list of exceptions that it may throw. Note that argument |
| 72 | +lists and exception lists are specified using the exact same syntax as |
| 73 | +field lists in struct or exception definitions. |
| 74 | +</pre><br/></div><div class="definition"><h4 id="Fn_Calculator_add">Function: Calculator.add</h4> |
| 75 | +<pre><code>i32</code> add(<code>i32</code> num1, |
| 76 | + <code>i32</code> num2) |
| 77 | +</pre></div><div class="definition"><h4 id="Fn_Calculator_calculate">Function: Calculator.calculate</h4> |
| 78 | +<pre><code>i32</code> calculate(<code>i32</code> logid, |
| 79 | + <code><a href="#Struct_Work">Work</a></code> w) |
| 80 | + throws <code><a href="#Struct_InvalidOperation">InvalidOperation</a></code> |
| 81 | +</pre></div><div class="definition"><h4 id="Fn_Calculator_zip">Function: Calculator.zip</h4> |
| 82 | +<pre><code>void</code> zip() |
| 83 | +</pre><pre>This method has a oneway modifier. That means the client only makes |
| 84 | +a request and does not listen for any response at all. Oneway methods |
| 85 | +must be void. |
| 86 | +</pre><br/></div></div></body></html> |
0 commit comments