Author: buildbot Date: Wed Sep 21 21:34:51 2016 New Revision: 997946 Log: Staging update by buildbot for thrift
Modified: websites/staging/thrift/trunk/content/ (props changed) websites/staging/thrift/trunk/content/about.html websites/staging/thrift/trunk/content/index.html websites/staging/thrift/trunk/content/lib/haxe.html websites/staging/thrift/trunk/content/test/ThriftTest.html websites/staging/thrift/trunk/content/test/keys.html websites/staging/thrift/trunk/content/tutorial/haxe.html websites/staging/thrift/trunk/content/tutorial/nodejs.html websites/staging/thrift/trunk/content/tutorial/py.html Propchange: websites/staging/thrift/trunk/content/ ------------------------------------------------------------------------------ --- cms:source-revision (original) +++ cms:source-revision Wed Sep 21 21:34:51 2016 @@ -1 +1 @@ -1737163 +1761817 Modified: websites/staging/thrift/trunk/content/about.html ============================================================================== --- websites/staging/thrift/trunk/content/about.html (original) +++ websites/staging/thrift/trunk/content/about.html Wed Sep 21 21:34:51 2016 @@ -297,11 +297,6 @@ h2:hover > .headerlink, h3:hover > .head </tr> <tr class=""> - <td class="company">Aereo</td> - <td class="website"><a href="http://www.aereo.com">http://www.aereo.com</a></td> - </tr> - - <tr class=""> <td class="company">Cloudera</td> <td class="website"><a href="http://www.cloudera.com">http://www.cloudera.com</a></td> </tr> Modified: websites/staging/thrift/trunk/content/index.html ============================================================================== --- websites/staging/thrift/trunk/content/index.html (original) +++ websites/staging/thrift/trunk/content/index.html Wed Sep 21 21:34:51 2016 @@ -213,7 +213,7 @@ h2:hover > .headerlink, h3:hover > .head <span class="n">client</span><span class="o">.</span><span class="n">ping</span><span class="p">()</span> <span class="k">print</span><span class="p">(</span><span class="s">'ping()'</span><span class="p">)</span> - <span class="nb">sum</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> + <span class="n">sum_</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </pre></div> <p class='snippet_footer'> This snippet was generated by Apache Thrift's <strong>source tree docs</strong>: Modified: websites/staging/thrift/trunk/content/lib/haxe.html ============================================================================== --- websites/staging/thrift/trunk/content/lib/haxe.html (original) +++ websites/staging/thrift/trunk/content/lib/haxe.html Wed Sep 21 21:34:51 2016 @@ -151,7 +151,8 @@ project files in these folders.</p> <h1 id="current-status">Current status<a class="headerlink" href="#current-status" title="Permanent link">¶</a></h1> <ul> <li>tested with Haxe C++ target</li> -<li>transports: Socket, HTTP (client only), Stream</li> +<li>tested with Haxe PHP target (console/web server, binary protocols)</li> +<li>transports: Socket, HTTP (servers run inside PHP server/PHP target only), Stream</li> <li>protocols: Binary, JSON, Multiplex, Compact</li> <li>tutorial client and server available</li> <li>cross-test client and server available </li> @@ -166,11 +167,56 @@ project files in these folders.</p> <p>Although designed with maximum portability in mind, for technical reasons some platforms may only support parts of the library, or not be compatible at all.</p> <p>Javascript: -- tutorial fails to build because of unsupported Sys.args +- tutorial fails to build because of unsupported Sys.args</p> +<h1 id="php-http-server-notes">PHP HTTP Server notes<a class="headerlink" href="#php-http-server-notes" title="Permanent link">¶</a></h1> +<ul> +<li> +<p>you have to import PHP files generated by haxe into PHP +<code>php +require_once dirname(__FILE__) . '/bin/php-web-server/Main-debug.php';</code></p> +</li> +<li> +<p>trace() by default outputs into stdout (http response), so you have to redirect it to stderr or you own logs, something like +<code>haxe +//remap trace to error log +haxe.Log.trace = function(v:Dynamic, ?infos:haxe.PosInfos) +{ + //simulate normal trace https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/Log.hx + var newValue : Dynamic; + if (infos != null && infos.customParams!=null) { + var extra:String = ""; + for( v in infos.customParams ) + extra += "," + v; + newValue = v + extra; + } + else { + newValue = v; + } + var msg = infos != null ? infos.fileName + ':' + infos.lineNumber + ': ' : ''; + Sys.stderr().writeString('${msg}${newValue}\n'); +}</code></p> +</li> +<li> +<p>to allow thrift server to read/write HTTP request/response, it should be pointed out to php streams +<code>haxe +transport = new TWrappingServerTransport( + new TStreamTransport( + new TFileStream("php://input", Read), + new TFileStream("php://output", Append) + ) + );</code></p> +</li> +<li> +<p>TSimpleServer doesn't stop after first call, so processor.process() should be called instead, or use runOnce property +<code>haxe +var server = new TSimpleServer( processor, transport, transfactory, protfactory); +server.runOnce = true;</code> <p class='snippet_footer'> This page was generated by Apache Thrift's <strong>source tree docs</strong>: <a href="http://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=lib/haxe/README.md;hb=HEAD"</a>lib/haxe/README.md</a> </p></p> +</li> +</ul> </div> <div class="container"> <hr> Modified: websites/staging/thrift/trunk/content/test/ThriftTest.html ============================================================================== --- websites/staging/thrift/trunk/content/test/ThriftTest.html (original) +++ websites/staging/thrift/trunk/content/test/ThriftTest.html Wed Sep 21 21:34:51 2016 @@ -580,7 +580,7 @@ struct Bools { struct Xtruct { 1: string string_thing, - 4: byte byte_thing, + 4: i8 byte_thing, 9: i32 i32_thing, 11: i64 i64_thing } @@ -658,7 +658,7 @@ service ThriftTest * @param byte thing - the i8/byte to print * @return i8 - returns the i8/byte 'thing' */ - i8 testByte(1: byte thing), + i8 testByte(1: i8 thing), /** * Prints 'testI32("%d")' with thing as '%d' @@ -771,7 +771,7 @@ service ThriftTest /** * Prints 'testMulti()' - * @param byte arg0 - + * @param i8 arg0 - * @param i32 arg1 - * @param i64 arg2 - * @param map<i16, string> arg3 - @@ -780,7 +780,7 @@ service ThriftTest * @return Xtruct - returns an Xtruct with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1 * and i64_thing = arg2 */ - Xtruct testMulti(1: byte arg0, 2: i32 arg1, 3: i64 arg2, 4: map<i16, string> arg3, 5: Numberz arg4, 6: UserId arg5), + Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map<i16, string> arg3, 5: Numberz arg4, 6: UserId arg5), /** * Print 'testException(%s)' with arg as '%s' @@ -831,7 +831,7 @@ struct VersioningTestV2 { 1: i32 begin_in_both, 2: i32 newint, - 3: byte newbyte, + 3: i8 newbyte, 4: i16 newshort, 5: i64 newlong, 6: double newdouble Modified: websites/staging/thrift/trunk/content/test/keys.html ============================================================================== --- websites/staging/thrift/trunk/content/test/keys.html (original) +++ websites/staging/thrift/trunk/content/test/keys.html Wed Sep 21 21:34:51 2016 @@ -148,6 +148,7 @@ Primary use are unit test suites and cro <span class="p">[</span> <span class="n">alternate_names</span> <span class="p">]</span> <span class="n">IP</span><span class="p">.</span>1<span class="p">=</span>127<span class="p">.</span>0<span class="p">.</span>0<span class="p">.</span>1 <span class="n">IP</span><span class="p">.</span>2<span class="p">=::</span>1 +<span class="n">IP</span><span class="p">.</span>3<span class="p">=::</span><span class="n">ffff</span><span class="p">:</span>127<span class="p">.</span>0<span class="p">.</span>0<span class="p">.</span>1 </pre></div> Modified: websites/staging/thrift/trunk/content/tutorial/haxe.html ============================================================================== --- websites/staging/thrift/trunk/content/tutorial/haxe.html (original) +++ websites/staging/thrift/trunk/content/tutorial/haxe.html Wed Sep 21 21:34:51 2016 @@ -125,293 +125,302 @@ import shared.</em>;</p> http; }</p> <p>class Main {</p> -<div class="codehilite"><pre><span class="n">private</span> <span class="n">static</span> <span class="n">var</span> <span class="n">server</span> <span class="p">:</span> <span class="n">Bool</span> <span class="p">=</span> <span class="n">false</span><span class="p">;</span> -<span class="n">private</span> <span class="n">static</span> <span class="n">var</span> <span class="n">framed</span> <span class="p">:</span> <span class="n">Bool</span> <span class="p">=</span> <span class="n">false</span><span class="p">;</span> -<span class="n">private</span> <span class="n">static</span> <span class="n">var</span> <span class="n">buffered</span> <span class="p">:</span> <span class="n">Bool</span> <span class="p">=</span> <span class="n">false</span><span class="p">;</span> -<span class="n">private</span> <span class="n">static</span> <span class="n">var</span> <span class="n">prot</span> <span class="p">:</span> <span class="n">Prot</span> <span class="p">=</span> <span class="n">binary</span><span class="p">;</span> -<span class="n">private</span> <span class="n">static</span> <span class="n">var</span> <span class="n">trns</span> <span class="p">:</span> <span class="n">Trns</span> <span class="p">=</span> <span class="n">socket</span><span class="p">;</span> - -<span class="n">private</span> <span class="n">static</span> <span class="n">var</span> <span class="n">targetHost</span> <span class="p">:</span> <span class="n">String</span> <span class="p">=</span> "<span class="n">localhost</span>"<span class="p">;</span> -<span class="n">private</span> <span class="n">static</span> <span class="n">var</span> <span class="n">targetPort</span> <span class="p">:</span> <span class="n">Int</span> <span class="p">=</span> 9090<span class="p">;</span> - -<span class="n">static</span> <span class="k">function</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> - #<span class="k">if</span> ! <span class="p">(</span><span class="n">flash</span> <span class="o">||</span> <span class="n">js</span><span class="p">)</span> - <span class="k">try</span> <span class="p">{</span> - <span class="n">ParseArgs</span><span class="p">();</span> - <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">e</span> <span class="p">:</span> <span class="n">String</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> - <span class="n">trace</span><span class="p">(</span><span class="n">GetHelp</span><span class="p">());</span> - <span class="k">return</span><span class="p">;</span> - <span class="p">}</span> - #<span class="k">end</span> - - <span class="k">try</span> <span class="p">{</span> - <span class="k">if</span> <span class="p">(</span><span class="n">server</span><span class="p">)</span> - <span class="n">RunServer</span><span class="p">();</span> - <span class="k">else</span> - <span class="n">RunClient</span><span class="p">();</span> - <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">e</span> <span class="p">:</span> <span class="n">String</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="n">e</span><span class="p">);</span> - <span class="p">}</span> - - <span class="n">trace</span><span class="p">(</span>"<span class="n">Completed</span><span class="p">.</span>"<span class="p">);</span> -<span class="p">}</span> - - -#<span class="k">if</span> ! <span class="p">(</span><span class="n">flash</span> <span class="o">||</span> <span class="n">js</span><span class="p">)</span> - -<span class="n">private</span> <span class="n">static</span> <span class="k">function</span> <span class="n">GetHelp</span><span class="p">()</span> <span class="p">:</span> <span class="n">String</span> <span class="p">{</span> - <span class="k">return</span> <span class="n">Sys</span><span class="p">.</span><span class="n">executablePath</span><span class="p">()</span><span class="o">+</span>" <span class="n">modus</span> <span class="n">trnsOption</span> <span class="n">transport</span> <span class="n">protocol</span><span class="o">\</span><span class="n">n</span>" - <span class="o">+</span>"<span class="n">Options</span><span class="p">:</span><span class="o">\</span><span class="n">n</span>" - <span class="o">+</span>" <span class="n">modus</span><span class="p">:</span> <span class="n">client</span><span class="p">,</span> <span class="n">server</span> <span class="p">(</span><span class="n">default</span><span class="p">:</span> <span class="n">client</span><span class="p">)</span><span class="o">\</span><span class="n">n</span>" - <span class="o">+</span>" <span class="n">trnsOption</span><span class="p">:</span> <span class="n">framed</span><span class="p">,</span> <span class="n">buffered</span> <span class="p">(</span><span class="n">default</span><span class="p">:</span> <span class="n">none</span><span class="p">)</span><span class="o">\</span><span class="n">n</span>" - <span class="o">+</span>" <span class="n">transport</span><span class="p">:</span> <span class="n">socket</span><span class="p">,</span> <span class="n">http</span> <span class="p">(</span><span class="n">default</span><span class="p">:</span> <span class="n">socket</span><span class="p">)</span><span class="o">\</span><span class="n">n</span>" - <span class="o">+</span>" <span class="n">protocol</span><span class="p">:</span> <span class="n">binary</span><span class="p">,</span> <span class="n">json</span> <span class="p">(</span><span class="n">default</span><span class="p">:</span> <span class="n">binary</span><span class="p">)</span><span class="o">\</span><span class="n">n</span>" - <span class="o">+</span>"<span class="o">\</span><span class="n">n</span>" - <span class="o">+</span>"<span class="n">All</span> <span class="n">arguments</span> <span class="n">are</span> <span class="n">optional</span><span class="o">.\</span><span class="n">n</span>"<span class="p">;</span> -<span class="p">}</span> - - -<span class="n">private</span> <span class="n">static</span> <span class="k">function</span> <span class="n">ParseArgs</span><span class="p">()</span> <span class="p">:</span> <span class="n">Void</span> <span class="p">{</span> - <span class="n">var</span> <span class="n">step</span> <span class="p">=</span> 0<span class="p">;</span> - <span class="k">for</span> <span class="p">(</span><span class="n">arg</span> <span class="n">in</span> <span class="n">Sys</span><span class="p">.</span><span class="n">args</span><span class="p">())</span> <span class="p">{</span> - - <span class="o">//</span> <span class="n">server</span><span class="o">|</span><span class="n">client</span> - <span class="k">switch</span><span class="p">(</span><span class="n">step</span><span class="p">)</span> <span class="p">{</span> - <span class="k">case</span> 0<span class="p">:</span> - <span class="o">++</span><span class="n">step</span><span class="p">;</span> - <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">client</span>"<span class="p">)</span> - <span class="n">server</span> <span class="p">=</span> <span class="n">false</span><span class="p">;</span> - <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">server</span>"<span class="p">)</span> - <span class="n">server</span> <span class="p">=</span> <span class="n">true</span><span class="p">;</span> - <span class="k">else</span> - <span class="n">throw</span> "<span class="n">First</span> <span class="n">argument</span> <span class="n">must</span> <span class="n">be</span> <span class="s">'server'</span> <span class="n">or</span> <span class="s">'client'</span>"<span class="p">;</span> - - <span class="k">case</span> 1<span class="p">:</span> - <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">framed</span>"<span class="p">)</span> <span class="p">{</span> - <span class="n">framed</span> <span class="p">=</span> <span class="n">true</span><span class="p">;</span> - <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">buffered</span>"<span class="p">)</span> <span class="p">{</span> - <span class="n">buffered</span> <span class="p">=</span> <span class="n">true</span><span class="p">;</span> - <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">socket</span>"<span class="p">)</span> <span class="p">{</span> - <span class="n">trns</span> <span class="p">=</span> <span class="n">socket</span><span class="p">;</span> - <span class="o">++</span><span class="n">step</span><span class="p">;</span> - <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">http</span>"<span class="p">)</span> <span class="p">{</span> - <span class="n">trns</span> <span class="p">=</span> <span class="n">http</span><span class="p">;</span> - <span class="o">++</span><span class="n">step</span><span class="p">;</span> - <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> - <span class="n">throw</span> "<span class="n">Unknown</span> <span class="n">transport</span> "<span class="o">+</span><span class="n">arg</span><span class="p">;</span> - <span class="p">}</span> - - <span class="k">case</span> 2<span class="p">:</span> - <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">binary</span>"<span class="p">)</span> <span class="p">{</span> - <span class="n">prot</span> <span class="p">=</span> <span class="n">binary</span><span class="p">;</span> - <span class="o">++</span><span class="n">step</span><span class="p">;</span> - <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="n">arg</span> <span class="o">==</span> "<span class="n">json</span>"<span class="p">)</span> <span class="p">{</span> - <span class="n">prot</span> <span class="p">=</span> <span class="n">json</span><span class="p">;</span> - <span class="o">++</span><span class="n">step</span><span class="p">;</span> - <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> - <span class="n">throw</span> "<span class="n">Unknown</span> <span class="n">protocol</span> "<span class="o">+</span><span class="n">arg</span><span class="p">;</span> - <span class="p">}</span> - - <span class="n">default</span><span class="p">:</span> - <span class="n">throw</span> "<span class="n">Unexpected</span> <span class="n">argument</span> "<span class="o">+</span><span class="n">arg</span><span class="p">;</span> - <span class="p">}</span> - - <span class="k">if</span> <span class="p">(</span> <span class="n">framed</span> <span class="o">&&</span> <span class="n">buffered</span><span class="p">)</span> - <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span>"<span class="n">WN</span><span class="p">:</span> <span class="n">framed</span> <span class="n">supersedes</span> <span class="n">buffered</span>"<span class="p">);</span> - <span class="p">}</span> - - <span class="p">}</span> -<span class="p">}</span> - -#<span class="k">end</span> - -<span class="n">private</span> <span class="n">static</span> <span class="k">function</span> <span class="n">ClientSetup</span><span class="p">()</span> <span class="p">:</span> <span class="n">Calculator</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span>"<span class="n">Client</span> <span class="n">configuration</span><span class="p">:</span>"<span class="p">);</span> - - <span class="o">//</span> <span class="n">endpoint</span> <span class="n">transport</span> - <span class="n">var</span> <span class="n">transport</span> <span class="p">:</span> <span class="n">TTransport</span><span class="p">;</span> - <span class="k">switch</span><span class="p">(</span><span class="n">trns</span><span class="p">)</span> - <span class="p">{</span> - <span class="k">case</span> <span class="n">socket</span><span class="p">:</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'- socket transport $targetHost:$targetPort'</span><span class="p">);</span> - <span class="n">transport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TSocket</span><span class="p">(</span> <span class="n">targetHost</span><span class="p">,</span> <span class="n">targetPort</span><span class="p">);</span> - <span class="k">case</span> <span class="n">http</span><span class="p">:</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'- HTTP transport $targetHost'</span><span class="p">);</span> - <span class="n">transport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">THttpClient</span><span class="p">(</span> <span class="n">targetHost</span><span class="p">);</span> - <span class="n">default</span><span class="p">:</span> - <span class="n">throw</span> "<span class="n">Unhandled</span> <span class="n">transport</span>"<span class="p">;</span> - <span class="p">}</span> - - - <span class="o">//</span> <span class="n">optinal</span> <span class="n">layered</span> <span class="n">transport</span> - <span class="k">if</span> <span class="p">(</span> <span class="n">framed</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">framed</span> <span class="n">transport</span>"<span class="p">);</span> - <span class="n">transport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TFramedTransport</span><span class="p">(</span><span class="n">transport</span><span class="p">);</span> - <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="n">buffered</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">buffered</span> <span class="n">transport</span>"<span class="p">);</span> - <span class="n">transport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TBufferedTransport</span><span class="p">(</span><span class="n">transport</span><span class="p">);</span> - <span class="p">}</span> - - - <span class="o">//</span> <span class="n">protocol</span> - <span class="n">var</span> <span class="n">protocol</span> <span class="p">:</span> <span class="n">TProtocol</span><span class="p">;</span> - <span class="k">switch</span><span class="p">(</span><span class="n">prot</span><span class="p">)</span> - <span class="p">{</span> - <span class="k">case</span> <span class="n">binary</span><span class="p">:</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">binary</span> <span class="n">protocol</span>"<span class="p">);</span> - <span class="n">protocol</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TBinaryProtocol</span><span class="p">(</span> <span class="n">transport</span><span class="p">);</span> - <span class="k">case</span> <span class="n">json</span><span class="p">:</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">JSON</span> <span class="n">protocol</span>"<span class="p">);</span> - <span class="n">protocol</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TJSONProtocol</span><span class="p">(</span> <span class="n">transport</span><span class="p">);</span> - <span class="n">default</span><span class="p">:</span> - <span class="n">throw</span> "<span class="n">Unhandled</span> <span class="n">protocol</span>"<span class="p">;</span> - <span class="p">}</span> - - - <span class="o">//</span> <span class="n">put</span> <span class="n">everything</span> <span class="n">together</span> - <span class="n">transport</span><span class="p">.</span><span class="n">open</span><span class="p">();</span> - <span class="k">return</span> <span class="n">new</span> <span class="n">CalculatorImpl</span><span class="p">(</span><span class="n">protocol</span><span class="p">,</span><span class="n">protocol</span><span class="p">);</span> -<span class="p">}</span> - - -<span class="n">private</span> <span class="n">static</span> <span class="k">function</span> <span class="n">RunClient</span><span class="p">()</span> <span class="p">:</span> <span class="n">Void</span> <span class="p">{</span> - <span class="n">var</span> <span class="n">client</span> <span class="p">=</span> <span class="n">ClientSetup</span><span class="p">();</span> - - <span class="k">try</span> <span class="p">{</span> - <span class="n">client</span><span class="p">.</span><span class="n">ping</span><span class="p">();</span> - <span class="n">trace</span><span class="p">(</span>"<span class="n">ping</span><span class="p">()</span> <span class="n">successful</span>"<span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">TException</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'ping() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'ping() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> - - <span class="k">try</span> <span class="p">{</span> - <span class="n">var</span> <span class="n">sum</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">add</span><span class="p">(</span> 1<span class="p">,</span> 1<span class="p">);</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'1+1=$sum'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">TException</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'add() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'add() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> - - - <span class="n">var</span> <span class="n">work</span> <span class="p">=</span> <span class="n">new</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">Work</span><span class="p">();</span> - <span class="n">work</span><span class="p">.</span><span class="n">op</span> <span class="p">=</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">Operation</span><span class="p">.</span><span class="n">DIVIDE</span><span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="p">=</span> 1<span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num2</span> <span class="p">=</span> 0<span class="p">;</span> - <span class="k">try</span> <span class="p">{</span> - <span class="n">var</span> <span class="n">quotient</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">calculate</span><span class="p">(</span> 1<span class="p">,</span> <span class="n">work</span><span class="p">);</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'Whoa we can divide by 0! Result = $quotient'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">TException</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'calculate() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'calculate() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> - - <span class="n">work</span><span class="p">.</span><span class="n">op</span> <span class="p">=</span> <span class="n">tutorial</span><span class="p">.</span><span class="n">Operation</span><span class="p">.</span><span class="n">SUBTRACT</span><span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num1</span> <span class="p">=</span> 15<span class="p">;</span> - <span class="n">work</span><span class="p">.</span><span class="n">num2</span> <span class="p">=</span> 10<span class="p">;</span> - <span class="k">try</span> <span class="p">{</span> - <span class="n">var</span> <span class="n">diff</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">calculate</span><span class="p">(</span> 1<span class="p">,</span> <span class="n">work</span><span class="p">);</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'15-10=$diff'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">TException</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'calculate() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'calculate() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> - - - <span class="k">try</span> <span class="p">{</span> - <span class="n">var</span> <span class="nb">log</span> <span class="p">:</span> <span class="n">SharedStruct</span> <span class="p">=</span> <span class="n">client</span><span class="p">.</span><span class="n">getStruct</span><span class="p">(</span> 1<span class="p">);</span> - <span class="n">var</span> <span class="n">logval</span> <span class="p">=</span> <span class="nb">log</span><span class="p">.</span><span class="n">value</span><span class="p">;</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'Check log: $logval'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">TException</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'getStruct() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> <span class="k">catch</span><span class="p">(</span><span class="n">error</span> <span class="p">:</span> <span class="n">Dynamic</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'getStruct() failed: $error'</span><span class="p">);</span> - <span class="p">}</span> -<span class="p">}</span> - - -<span class="n">private</span> <span class="n">static</span> <span class="k">function</span> <span class="n">ServerSetup</span><span class="p">()</span> <span class="p">:</span> <span class="n">TServer</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span>"<span class="n">Server</span> <span class="n">configuration</span><span class="p">:</span>"<span class="p">);</span> - - <span class="o">//</span> <span class="n">endpoint</span> <span class="n">transport</span> - <span class="n">var</span> <span class="n">transport</span> <span class="p">:</span> <span class="n">TServerTransport</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span> - <span class="k">switch</span><span class="p">(</span><span class="n">trns</span><span class="p">)</span> - <span class="p">{</span> - <span class="k">case</span> <span class="n">socket</span><span class="p">:</span> - #<span class="k">if</span> <span class="p">(</span><span class="n">flash</span> <span class="o">||</span> <span class="n">js</span><span class="p">)</span> - <span class="n">throw</span> <span class="s">'current platform does not support socket servers'</span><span class="p">;</span> - #<span class="k">else</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'- socket transport port $targetPort'</span><span class="p">);</span> - <span class="n">transport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TServerSocket</span><span class="p">(</span> <span class="n">targetPort</span><span class="p">);</span> - #<span class="k">end</span> - <span class="k">case</span> <span class="n">http</span><span class="p">:</span> - <span class="n">throw</span> "<span class="n">HTTP</span> <span class="n">server</span> <span class="n">not</span> <span class="n">implemented</span> <span class="n">yet</span>"<span class="p">;</span> - <span class="o">//</span><span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">http</span> <span class="n">transport</span>"<span class="p">);</span> - <span class="o">//</span><span class="n">transport</span> <span class="p">=</span> <span class="n">new</span> <span class="n">THttpClient</span><span class="p">(</span> <span class="n">targetHost</span><span class="p">);</span> - <span class="n">default</span><span class="p">:</span> - <span class="n">throw</span> "<span class="n">Unhandled</span> <span class="n">transport</span>"<span class="p">;</span> - <span class="p">}</span> - - <span class="o">//</span> <span class="n">optional</span><span class="p">:</span> <span class="n">layered</span> <span class="n">transport</span> - <span class="n">var</span> <span class="n">transfactory</span> <span class="p">:</span> <span class="n">TTransportFactory</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span> - <span class="k">if</span> <span class="p">(</span> <span class="n">framed</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">framed</span> <span class="n">transport</span>"<span class="p">);</span> - <span class="n">transfactory</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TFramedTransportFactory</span><span class="p">();</span> - <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span> <span class="n">buffered</span><span class="p">)</span> <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">buffered</span> <span class="n">transport</span>"<span class="p">);</span> - <span class="n">transfactory</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TBufferedTransportFactory</span><span class="p">();</span> - <span class="p">}</span> - - <span class="o">//</span> <span class="n">protocol</span> - <span class="n">var</span> <span class="n">protfactory</span> <span class="p">:</span> <span class="n">TProtocolFactory</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span> - <span class="k">switch</span><span class="p">(</span><span class="n">prot</span><span class="p">)</span> - <span class="p">{</span> - <span class="k">case</span> <span class="n">binary</span><span class="p">:</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">binary</span> <span class="n">protocol</span>"<span class="p">);</span> - <span class="n">protfactory</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TBinaryProtocolFactory</span><span class="p">();</span> - <span class="k">case</span> <span class="n">json</span><span class="p">:</span> - <span class="n">trace</span><span class="p">(</span>"<span class="o">-</span> <span class="n">JSON</span> <span class="n">protocol</span>"<span class="p">);</span> - <span class="n">protfactory</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TJSONProtocolFactory</span><span class="p">();</span> - <span class="n">default</span><span class="p">:</span> - <span class="n">throw</span> "<span class="n">Unhandled</span> <span class="n">protocol</span>"<span class="p">;</span> - <span class="p">}</span> - - <span class="n">var</span> <span class="n">handler</span> <span class="p">=</span> <span class="n">new</span> <span class="n">CalculatorHandler</span><span class="p">();</span> - <span class="n">var</span> <span class="n">processor</span> <span class="p">=</span> <span class="n">new</span> <span class="n">CalculatorProcessor</span><span class="p">(</span><span class="n">handler</span><span class="p">);</span> - <span class="n">var</span> <span class="n">server</span> <span class="p">=</span> <span class="n">new</span> <span class="n">TSimpleServer</span><span class="p">(</span> <span class="n">processor</span><span class="p">,</span> <span class="n">transport</span><span class="p">,</span> <span class="n">transfactory</span><span class="p">,</span> <span class="n">protfactory</span><span class="p">);</span> - <span class="k">return</span> <span class="n">server</span><span class="p">;</span> -<span class="p">}</span> - - -<span class="n">private</span> <span class="n">static</span> <span class="k">function</span> <span class="n">RunServer</span><span class="p">()</span> <span class="p">:</span> <span class="n">Void</span> <span class="p">{</span> - <span class="k">try</span> - <span class="p">{</span> - <span class="n">var</span> <span class="n">server</span> <span class="p">=</span> <span class="n">ServerSetup</span><span class="p">();</span> - - <span class="n">trace</span><span class="p">(</span>"<span class="o">\</span><span class="n">nStarting</span> <span class="n">the</span> <span class="n">server</span><span class="p">...</span>"<span class="p">);</span> - <span class="n">server</span><span class="p">.</span><span class="n">Serve</span><span class="p">();</span> - <span class="p">}</span> - <span class="k">catch</span><span class="p">(</span> <span class="n">e</span> <span class="p">:</span> <span class="n">Dynamic</span><span class="p">)</span> - <span class="p">{</span> - <span class="n">trace</span><span class="p">(</span><span class="s">'RunServer() failed: $e'</span><span class="p">);</span> - <span class="p">}</span> - <span class="n">trace</span><span class="p">(</span>"<span class="n">done</span><span class="p">.</span>"<span class="p">);</span> -<span class="p">}</span> +<div class="codehilite"><pre>private static var server : Bool = false; +private static var framed : Bool = false; +private static var buffered : Bool = false; +private static var prot : Prot = binary; +private static var trns : Trns = socket; + +private static var targetHost : String = "localhost"; +private static var targetPort : Int = 9090; + +static function main() { + + #if ! (flash || js || phpwebserver) + try { + ParseArgs(); + } catch (e : String) { + trace(e); + trace(GetHelp()); + return; + } + + #elseif phpwebserver + //forcing server + server = true; + trns = http; + initPhpWebServer(); + //check method + if(php.Web.getMethod() != 'POST') { + Sys.println('http endpoint for thrift test server'); + return; + } + #end + + try { + if (server) + RunServer(); + else + RunClient(); + } catch (e : String) { + trace(e); + } + + trace("Completed."); +} + +#if phpwebserver +private static function initPhpWebServer() +{ + //remap trace to error log + haxe.Log.trace = function(v:Dynamic, ?infos:haxe.PosInfos) + { + // handle trace + var newValue : Dynamic; + if (infos != null <span class="err">&&</span> infos.customParams!=null) { + var extra:String = ""; + for( v in infos.customParams ) + extra += "," + v; + newValue = v + extra; + } + else { + newValue = v; + } + var msg = infos != null ? infos.fileName + ':' + infos.lineNumber + ': ' : ''; + Sys.stderr().writeString('<span class="cp">${</span><span class="n">msg</span><span class="cp">}${</span><span class="n">newValue</span><span class="cp">}</span>\n'); + } +} +#end + + +#if ! (flash || js) + +private static function GetHelp() : String { + return Sys.executablePath()+" modus trnsOption transport protocol\n" + +"Options:\n" + +" modus: client, server (default: client)\n" + +" trnsOption: framed, buffered (default: none)\n" + +" transport: socket, http (default: socket)\n" + +" protocol: binary, json (default: binary)\n" + +"\n" + +"All arguments are optional.\n"; +} + + +private static function ParseArgs() : Void { + var step = 0; + for (arg in Sys.args()) { + + // server|client + switch(step) { + case 0: + ++step; + if ( arg == "client") + server = false; + else if ( arg == "server") + server = true; + else + throw "First argument must be 'server' or 'client'"; + + case 1: + if ( arg == "framed") { + framed = true; + } else if ( arg == "buffered") { + buffered = true; + } else if ( arg == "socket") { + trns = socket; + ++step; + } else if ( arg == "http") { + trns = http; + ++step; + } else { + throw "Unknown transport "+arg; + } + + case 2: + if ( arg == "binary") { + prot = binary; + ++step; + } else if ( arg == "json") { + prot = json; + ++step; + } else { + throw "Unknown protocol "+arg; + } + + default: + throw "Unexpected argument "+arg; + } + + if ( framed <span class="err">&&</span> buffered) + { + trace("WN: framed supersedes buffered"); + } + + } +} + +#end + +private static function ClientSetup() : Calculator { + trace("Client configuration:"); + + // endpoint transport + var transport : TTransport; + switch(trns) + { + case socket: + trace('- socket transport <span class="nv">$targetHost</span>:<span class="nv">$targetPort</span>'); + transport = new TSocket( targetHost, targetPort); + case http: + var uri = 'http://<span class="cp">${</span><span class="n">targetHost</span><span class="cp">}</span>:<span class="cp">${</span><span class="n">targetPort</span><span class="cp">}</span>'; + trace('- HTTP transport <span class="nv">$uri</span>'); + transport = new THttpClient(uri); + default: + throw "Unhandled transport"; + } + + + // optinal layered transport + if ( framed) { + trace("- framed transport"); + transport = new TFramedTransport(transport); + } else if ( buffered) { + trace("- buffered transport"); + transport = new TBufferedTransport(transport); + } + + + // protocol + var protocol : TProtocol; + switch(prot) + { + case binary: + trace("- binary protocol"); + protocol = new TBinaryProtocol( transport); + case json: + trace("- JSON protocol"); + protocol = new TJSONProtocol( transport); + default: + throw "Unhandled protocol"; + } + + + // put everything together + transport.open(); + return new CalculatorImpl(protocol,protocol); +} + + +private static function RunClient() : Void { + var client = ClientSetup(); + + try { + client.ping(); + trace("ping() successful"); + } catch(error : TException) { + trace('ping() failed: <span class="nv">$error</span>'); + } catch(error : Dynamic) { + trace('ping() failed: <span class="nv">$error</span>'); + } + + try { + var sum = client.add( 1, 1); + trace('1+1=<span class="nv">$sum</span>'); + } catch(error : TException) { + trace('add() failed: <span class="nv">$error</span>'); + } catch(error : Dynamic) { + trace('add() failed: <span class="nv">$error</span>'); + } + + + var work = new tutorial.Work(); + work.op = tutorial.Operation.DIVIDE; + work.num1 = 1; + work.num2 = 0; + try { + var quotient = client.calculate( 1, work); + trace('Whoa we can divide by 0! Result = <span class="nv">$quotient</span>'); + } catch(error : TException) { + trace('calculate() failed: <span class="nv">$error</span>'); + } catch(error : Dynamic) { + trace('calculate() failed: <span class="nv">$error</span>'); + } + + work.op = tutorial.Operation.SUBTRACT; + work.num1 = 15; + work.num2 = 10; + try { + var diff = client.calculate( 1, work); + trace('15-10=<span class="nv">$diff</span>'); + } catch(error : TException) { + trace('calculate() failed: <span class="nv">$error</span>'); + } catch(error : Dynamic) { + trace('calculate() failed: <span class="nv">$error</span>'); + } + + + try { + var log : SharedStruct = client.getStruct( 1); + var logval = log.value; + trace('Check log: <span class="nv">$logval</span>'); + } catch(error : TException) { + trace('getStruct() failed: <span class="nv">$error</span>'); + } catch(error : Dynamic) { + trace('getStruct() failed: <span class="nv">$error</span>'); + } +} + + +private static function ServerSetup() : TServer { + trace("Server configuration:"); + + // endpoint transport + var transport : TServerTransport = null; + switch(trns) + { + case socket: + #if (flash || js) + throw 'current platform does not support socket servers'; + #else + trace('- socket transport port <span class="nv">$targetPort</span>'); + transport = new TServerSocket( targetPort); + #end + case http: + #if !phpwebserver + throw "HTTP server not implemented yet"; + //trace("- http transport"); + //transport = new THttpClient( targetHost); + #else + trace("- http transport"); + transport = new TWrappingServerTransport( + new TStreamTransport( + new TFileStream("php://input", Read), + new TFileStream("php://output", Append) + ) + ); + + #end + default: + throw "Unhandled transport"; + } + + // optional: layered transport + var transfactory : TTransportFactory = null; + if ( framed) { + trace("- framed transport"); + transfactory = new TFramedTransportFactory(); + } else if ( buffered) { + trace("- buffered transport"); + transfactory = new TBufferedTransportFactory(); + } </pre></div> -<p>}</p> -<p class='snippet_footer'> +<p><p class='snippet_footer'> This snippet was generated by Apache Thrift's <strong>source tree docs</strong>: <a href="http://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=tutorial/haxe/src/Main.hx;hb=HEAD"</a>tutorial/haxe/src/Main.hx</a> -</p> - +</p></p> <p>Were done with the client, but need some more for the server: A service handler implementaion.</p> <h3 id="server">Server<a class="headerlink" href="#server" title="Permanent link">¶</a></h3> <p>As the name suggests, the service handler implements the Thrift service on the server side. Modified: websites/staging/thrift/trunk/content/tutorial/nodejs.html ============================================================================== --- websites/staging/thrift/trunk/content/tutorial/nodejs.html (original) +++ websites/staging/thrift/trunk/content/tutorial/nodejs.html Wed Sep 21 21:34:51 2016 @@ -116,13 +116,11 @@ h2:hover > .headerlink, h3:hover > .head h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style> <div class="codehilite"><pre><span class="kd">var</span> <span class="nx">thrift</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'thrift'</span><span class="p">);</span> -<span class="kd">var</span> <span class="nx">ThriftTransports</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'thrift/transport'</span><span class="p">);</span> -<span class="kd">var</span> <span class="nx">ThriftProtocols</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'thrift/protocol'</span><span class="p">);</span> <span class="kd">var</span> <span class="nx">Calculator</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'./gen-nodejs/Calculator'</span><span class="p">);</span> <span class="kd">var</span> <span class="nx">ttypes</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'./gen-nodejs/tutorial_types'</span><span class="p">);</span> -<span class="nx">transport</span> <span class="o">=</span> <span class="nx">ThriftTransports</span><span class="p">.</span><span class="nx">TBufferedTransport</span><span class="p">()</span> -<span class="nx">protocol</span> <span class="o">=</span> <span class="nx">ThriftProtocols</span><span class="p">.</span><span class="nx">TBinaryProtocol</span><span class="p">()</span> +<span class="kd">var</span> <span class="nx">transport</span> <span class="o">=</span> <span class="nx">thrift</span><span class="p">.</span><span class="nx">TBufferedTransport</span><span class="p">;</span> +<span class="kd">var</span> <span class="nx">protocol</span> <span class="o">=</span> <span class="nx">thrift</span><span class="p">.</span><span class="nx">TBinaryProtocol</span><span class="p">;</span> <span class="kd">var</span> <span class="nx">connection</span> <span class="o">=</span> <span class="nx">thrift</span><span class="p">.</span><span class="nx">createConnection</span><span class="p">(</span><span class="s2">"localhost"</span><span class="p">,</span> <span class="mi">9090</span><span class="p">,</span> <span class="p">{</span> <span class="nx">transport</span> <span class="o">:</span> <span class="nx">transport</span><span class="p">,</span> Modified: websites/staging/thrift/trunk/content/tutorial/py.html ============================================================================== --- websites/staging/thrift/trunk/content/tutorial/py.html (original) +++ websites/staging/thrift/trunk/content/tutorial/py.html Wed Sep 21 21:34:51 2016 @@ -148,8 +148,8 @@ h2:hover > .headerlink, h3:hover > .head <span class="n">client</span><span class="o">.</span><span class="n">ping</span><span class="p">()</span> <span class="k">print</span><span class="p">(</span><span class="s">'ping()'</span><span class="p">)</span> - <span class="nb">sum</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> - <span class="k">print</span><span class="p">((</span><span class="s">'1+1=</span><span class="si">%d</span><span class="s">'</span> <span class="o">%</span> <span class="p">(</span><span class="nb">sum</span><span class="p">)))</span> + <span class="n">sum_</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> + <span class="k">print</span><span class="p">(</span><span class="s">'1+1=</span><span class="si">%d</span><span class="s">'</span> <span class="o">%</span> <span class="n">sum_</span><span class="p">)</span> <span class="n">work</span> <span class="o">=</span> <span class="n">Work</span><span class="p">()</span> @@ -162,17 +162,17 @@ h2:hover > .headerlink, h3:hover > .head <span class="k">print</span><span class="p">(</span><span class="s">'Whoa? You know how to divide by zero?'</span><span class="p">)</span> <span class="k">print</span><span class="p">(</span><span class="s">'FYI the answer is </span><span class="si">%d</span><span class="s">'</span> <span class="o">%</span> <span class="n">quotient</span><span class="p">)</span> <span class="k">except</span> <span class="n">InvalidOperation</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> - <span class="k">print</span><span class="p">((</span><span class="s">'InvalidOperation: </span><span class="si">%r</span><span class="s">'</span> <span class="o">%</span> <span class="n">e</span><span class="p">))</span> + <span class="k">print</span><span class="p">(</span><span class="s">'InvalidOperation: </span><span class="si">%r</span><span class="s">'</span> <span class="o">%</span> <span class="n">e</span><span class="p">)</span> <span class="n">work</span><span class="o">.</span><span class="n">op</span> <span class="o">=</span> <span class="n">Operation</span><span class="o">.</span><span class="n">SUBTRACT</span> <span class="n">work</span><span class="o">.</span><span class="n">num1</span> <span class="o">=</span> <span class="mi">15</span> <span class="n">work</span><span class="o">.</span><span class="n">num2</span> <span class="o">=</span> <span class="mi">10</span> <span class="n">diff</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">calculate</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">work</span><span class="p">)</span> - <span class="k">print</span><span class="p">((</span><span class="s">'15-10=</span><span class="si">%d</span><span class="s">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">diff</span><span class="p">)))</span> + <span class="k">print</span><span class="p">(</span><span class="s">'15-10=</span><span class="si">%d</span><span class="s">'</span> <span class="o">%</span> <span class="n">diff</span><span class="p">)</span> <span class="n">log</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">getStruct</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> - <span class="k">print</span><span class="p">((</span><span class="s">'Check log: </span><span class="si">%s</span><span class="s">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">log</span><span class="o">.</span><span class="n">value</span><span class="p">)))</span> + <span class="k">print</span><span class="p">(</span><span class="s">'Check log: </span><span class="si">%s</span><span class="s">'</span> <span class="o">%</span> <span class="n">log</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> <span class="c"># Close!</span> <span class="n">transport</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> @@ -269,8 +269,9 @@ h2:hover > .headerlink, h3:hover > .head <span class="n">server</span> <span class="o">=</span> <span class="n">TServer</span><span class="o">.</span><span class="n">TSimpleServer</span><span class="p">(</span><span class="n">processor</span><span class="p">,</span> <span class="n">transport</span><span class="p">,</span> <span class="n">tfactory</span><span class="p">,</span> <span class="n">pfactory</span><span class="p">)</span> <span class="c"># You could do one of these for a multithreaded server</span> - <span class="c"># server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)</span> - <span class="c"># server = TServer.TThreadPoolServer(processor, transport, tfactory, pfactory)</span> + <span class="c"># server = TServer.TThreadedServer(</span> + <span class="c"># processor, transport, tfactory, pfactory)</span> + <span class="c"># server = TServer.TThreadPoolServer(</span> </pre></div> <p class='snippet_footer'>