You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/02/02 17:12:34 UTC
svn commit: r1563648 [2/2] - in /thrift/site/publish: ./ about/ developers/
docs/ docs/BuildingFromSource/ docs/HowToContribute/ docs/committers/
docs/committers/AdditionalReading/ docs/committers/HowToPublish/
docs/committers/HowToRelease/ docs/commit...
Modified: thrift/site/publish/tutorial/nodejs/index.html
URL: http://svn.apache.org/viewvc/thrift/site/publish/tutorial/nodejs/index.html?rev=1563648&r1=1563647&r2=1563648&view=diff
==============================================================================
--- thrift/site/publish/tutorial/nodejs/index.html (original)
+++ thrift/site/publish/tutorial/nodejs/index.html Sun Feb 2 16:12:33 2014
@@ -68,14 +68,12 @@
<div class="container">
<h2>Node.js Tutorial</h2>
-<hr>
-
-<h3>Introduction</h3>
+<hr><h3>Introduction</h3>
<p>All Apache Thrift tutorials require that you have:</p>
<ol>
-<li>Built and installed the Apache Thrift Compiler, see <a href="/docs/install/">installing Thrift</a> for more details. </li>
+<li>Built and installed the Apache Thrift Compiler and Libraries, see <a href="/docs/BuildingFromSource/">Building from source</a> for more details. </li>
<li>
<p>Generated the <a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a> file as <a href="/tutorial/">discussed here</a></p>
@@ -83,18 +81,139 @@
</code></pre>
</li>
<li><p>Followed all prerequesets listed </p></li>
-</ol>
-
-<h3>Prerequisites</h3>
+</ol><h3>Prerequisites</h3>
<h3>Client</h3>
-<div class="CodeRay"><div class="code"><pre><code class="language-js"></code></pre></div></div>
+<div class="CodeRay"><div class="code"><pre><code class="language-js"><span style="color:#080;font-weight:bold">var</span> thrift = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">thrift</span><span style="color:#710">'</span></span>);
+<span style="color:#080;font-weight:bold">var</span> ThriftTransports = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">thrift/transport</span><span style="color:#710">'</span></span>);
+<span style="color:#080;font-weight:bold">var</span> ThriftProtocols = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">thrift/protocol</span><span style="color:#710">'</span></span>);
+<span style="color:#080;font-weight:bold">var</span> Calculator = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">./gen-nodejs/Calculator</span><span style="color:#710">'</span></span>);
+<span style="color:#080;font-weight:bold">var</span> ttypes = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">./gen-nodejs/tutorial_types</span><span style="color:#710">'</span></span>);
+
+
+transport = ThriftTransports.TBufferedTransport()
+protocol = ThriftProtocols.TBinaryProtocol()
+
+<span style="color:#080;font-weight:bold">var</span> connection = thrift.createConnection(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">localhost</span><span style="color:#710">"</span></span>, <span style="color:#00D">9090</span>, {
+ <span style="color:#606">transport</span> : transport,
+ <span style="color:#606">protocol</span> : protocol
+});
+
+connection.on(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">error</span><span style="color:#710">'</span></span>, <span style="color:#080;font-weight:bold">function</span>(err) {
+ assert(<span style="color:#069">false</span>, err);
+});
+
+<span style="color:#777">// Create a Calculator client with the connection</span>
+<span style="color:#080;font-weight:bold">var</span> client = thrift.createClient(Calculator, connection);
+
+
+client.ping(<span style="color:#080;font-weight:bold">function</span>(err, response) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">ping()</span><span style="color:#710">'</span></span>);
+});
+
+
+client.add(<span style="color:#00D">1</span>,<span style="color:#00D">1</span>, <span style="color:#080;font-weight:bold">function</span>(err, response) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">1+1=</span><span style="color:#710">"</span></span> + response);
+});
+
+
+work = <span style="color:#080;font-weight:bold">new</span> ttypes.Work();
+work.op = ttypes.Operation.DIVIDE;
+work.num1 = <span style="color:#00D">1</span>;
+work.num2 = <span style="color:#00D">0</span>;
+
+client.calculate(<span style="color:#00D">1</span>, work, <span style="color:#080;font-weight:bold">function</span>(err, message) {
+ <span style="color:#080;font-weight:bold">if</span> (err) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">InvalidOperation </span><span style="color:#710">"</span></span> + err);
+ } <span style="color:#080;font-weight:bold">else</span> {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Whoa? You know how to divide by zero?</span><span style="color:#710">'</span></span>);
+ }
+});
+
+work.op = ttypes.Operation.SUBTRACT;
+work.num1 = <span style="color:#00D">15</span>;
+work.num2 = <span style="color:#00D">10</span>;
+
+client.calculate(<span style="color:#00D">1</span>, work, <span style="color:#080;font-weight:bold">function</span>(err, message) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">15-10=</span><span style="color:#710">'</span></span> + message.value);
+
+ client.getStruct(<span style="color:#00D">1</span>, <span style="color:#080;font-weight:bold">function</span>(err, message){
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Check log: </span><span style="color:#710">'</span></span> + message.value);
+
+ <span style="color:#777">//close the connection once we're done</span>
+ connection.end();
+ });
+});</code></pre></div></div>
<h3>Server</h3>
-<h2>Additional Information</h2>
+<div class="CodeRay"><div class="code"><pre><code class="language-js"><span style="color:#080;font-weight:bold">var</span> thrift = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">thrift</span><span style="color:#710">"</span></span>);
+<span style="color:#080;font-weight:bold">var</span> Calculator = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">./gen-nodejs/Calculator</span><span style="color:#710">"</span></span>);
+<span style="color:#080;font-weight:bold">var</span> ttypes = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">./gen-nodejs/tutorial_types</span><span style="color:#710">"</span></span>);
+<span style="color:#080;font-weight:bold">var</span> SharedStruct = require(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">./gen-nodejs/shared_types</span><span style="color:#710">"</span></span>).SharedStruct;
+
+<span style="color:#080;font-weight:bold">var</span> data = {};
+
+<span style="color:#080;font-weight:bold">var</span> server = thrift.createServer(Calculator, {
+ <span style="color:#06B;font-weight:bold">ping</span>: <span style="color:#080;font-weight:bold">function</span>(result) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">ping()</span><span style="color:#710">"</span></span>);
+ result(<span style="color:#069">null</span>);
+ },
+
+ <span style="color:#06B;font-weight:bold">add</span>: <span style="color:#080;font-weight:bold">function</span>(n1, n2, result) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">add(</span><span style="color:#710">"</span></span>, n1, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">,</span><span style="color:#710">"</span></span>, n2, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">)</span><span style="color:#710">"</span></span>);
+ result(<span style="color:#069">null</span>, n1 + n2);
+ },
+
+ <span style="color:#06B;font-weight:bold">calculate</span>: <span style="color:#080;font-weight:bold">function</span>(logid, work, result) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">calculate(</span><span style="color:#710">"</span></span>, logid, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">,</span><span style="color:#710">"</span></span>, work, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">)</span><span style="color:#710">"</span></span>);
+
+ <span style="color:#080;font-weight:bold">var</span> val = <span style="color:#00D">0</span>;
+ <span style="color:#080;font-weight:bold">if</span> (work.op == ttypes.Operation.ADD) {
+ val = work.num1 + work.num2;
+ } <span style="color:#080;font-weight:bold">else</span> <span style="color:#080;font-weight:bold">if</span> (work.op === ttypes.Operation.SUBTRACT) {
+ val = work.num1 - work.num2;
+ } <span style="color:#080;font-weight:bold">else</span> <span style="color:#080;font-weight:bold">if</span> (work.op === ttypes.Operation.MULTIPLY) {
+ val = work.num1 * work.num2;
+ } <span style="color:#080;font-weight:bold">else</span> <span style="color:#080;font-weight:bold">if</span> (work.op === ttypes.Operation.DIVIDE) {
+ <span style="color:#080;font-weight:bold">if</span> (work.num2 === <span style="color:#00D">0</span>) {
+ <span style="color:#080;font-weight:bold">var</span> x = <span style="color:#080;font-weight:bold">new</span> ttypes.InvalidOperation();
+ x.what = work.op;
+ x.why = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Cannot divide by 0</span><span style="color:#710">'</span></span>;
+ result(x);
+ <span style="color:#080;font-weight:bold">return</span>;
+ }
+ val = work.num1 / work.num2;
+ } <span style="color:#080;font-weight:bold">else</span> {
+ <span style="color:#080;font-weight:bold">var</span> x = <span style="color:#080;font-weight:bold">new</span> ttypes.InvalidOperation();
+ x.what = work.op;
+ x.why = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Invalid operation</span><span style="color:#710">'</span></span>;
+ result(x);
+ <span style="color:#080;font-weight:bold">return</span>;
+ }
+
+ <span style="color:#080;font-weight:bold">var</span> entry = <span style="color:#080;font-weight:bold">new</span> SharedStruct();
+ entry.key = logid;
+ entry.value = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#710">"</span></span>+val;
+ data[logid] = entry;
+
+ result(<span style="color:#069">null</span>, val);
+ },
+
+ <span style="color:#06B;font-weight:bold">getStruct</span>: <span style="color:#080;font-weight:bold">function</span>(key, result) {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">getStruct(</span><span style="color:#710">"</span></span>, key, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">)</span><span style="color:#710">"</span></span>);
+ result(<span style="color:#069">null</span>, data[key]);
+ },
+
+ <span style="color:#06B;font-weight:bold">zip</span>: <span style="color:#080;font-weight:bold">function</span>() {
+ console.log(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">zip()</span><span style="color:#710">"</span></span>);
+ result(<span style="color:#069">null</span>);
+ }
+
+});
+server.listen(<span style="color:#00D">9090</span>);</code></pre></div></div>
</div>
<div class="container">
<hr>
Modified: thrift/site/publish/tutorial/ocaml/index.html
URL: http://svn.apache.org/viewvc/thrift/site/publish/tutorial/ocaml/index.html?rev=1563648&r1=1563647&r2=1563648&view=diff
==============================================================================
--- thrift/site/publish/tutorial/ocaml/index.html (original)
+++ thrift/site/publish/tutorial/ocaml/index.html Sun Feb 2 16:12:33 2014
@@ -68,14 +68,12 @@
<div class="container">
<h2>OCaml Tutorial</h2>
-<hr>
-
-<h3>Introduction</h3>
+<hr><h3>Introduction</h3>
<p>All Apache Thrift tutorials require that you have:</p>
<ol>
-<li>Built and installed the Apache Thrift Compiler, see <a href="/docs/install/">installing Thrift</a> for more details. </li>
+<li>Built and installed the Apache Thrift Compiler and Libraries, see <a href="/docs/BuildingFromSource/">Building from source</a> for more details. </li>
<li>
<p>Generated the <a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a> file as <a href="/tutorial/">discussed here</a></p>
@@ -83,9 +81,7 @@
</code></pre>
</li>
<li><p>Followed all prerequesets listed </p></li>
-</ol>
-
-<h3>Prerequisites</h3>
+</ol><h3>Prerequisites</h3>
<h3>Client</h3>
@@ -94,7 +90,6 @@
<h3>Server</h3>
<h2>Additional Information</h2>
-
</div>
<div class="container">
<hr>
Modified: thrift/site/publish/tutorial/perl/index.html
URL: http://svn.apache.org/viewvc/thrift/site/publish/tutorial/perl/index.html?rev=1563648&r1=1563647&r2=1563648&view=diff
==============================================================================
--- thrift/site/publish/tutorial/perl/index.html (original)
+++ thrift/site/publish/tutorial/perl/index.html Sun Feb 2 16:12:33 2014
@@ -68,14 +68,12 @@
<div class="container">
<h2>Perl Tutorial</h2>
-<hr>
-
-<h3>Introduction</h3>
+<hr><h3>Introduction</h3>
<p>All Apache Thrift tutorials require that you have:</p>
<ol>
-<li>Built and installed the Apache Thrift Compiler, see <a href="/docs/install/">installing Thrift</a> for more details. </li>
+<li>Built and installed the Apache Thrift Compiler and Libraries, see <a href="/docs/BuildingFromSource/">Building from source</a> for more details. </li>
<li>
<p>Generated the <a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a> file as <a href="/tutorial/">discussed here</a></p>
@@ -83,9 +81,7 @@
</code></pre>
</li>
<li><p>Followed all prerequesets listed </p></li>
-</ol>
-
-<h3>Prerequisites</h3>
+</ol><h3>Prerequisites</h3>
<h3>Client</h3>
@@ -94,7 +90,6 @@
<h3>Server</h3>
<h2>Additional Information</h2>
-
</div>
<div class="container">
<hr>
Modified: thrift/site/publish/tutorial/php/index.html
URL: http://svn.apache.org/viewvc/thrift/site/publish/tutorial/php/index.html?rev=1563648&r1=1563647&r2=1563648&view=diff
==============================================================================
--- thrift/site/publish/tutorial/php/index.html (original)
+++ thrift/site/publish/tutorial/php/index.html Sun Feb 2 16:12:33 2014
@@ -68,14 +68,12 @@
<div class="container">
<h2>PHP Tutorial</h2>
-<hr>
-
-<h3>Introduction</h3>
+<hr><h3>Introduction</h3>
<p>All Apache Thrift tutorials require that you have:</p>
<ol>
-<li>Built and installed the Apache Thrift Compiler, see <a href="/docs/install/">installing Thrift</a> for more details. </li>
+<li>Built and installed the Apache Thrift Compiler and Libraries, see <a href="/docs/BuildingFromSource/">Building from source</a> for more details. </li>
<li>
<p>Generated the <a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a> file as <a href="/tutorial/">discussed here</a></p>
@@ -83,9 +81,7 @@
</code></pre>
</li>
<li><p>Followed all prerequesets listed </p></li>
-</ol>
-
-<h3>Prerequisites</h3>
+</ol><h3>Prerequisites</h3>
<h3>Client</h3>
@@ -94,7 +90,6 @@
<h3>Server</h3>
<h2>Additional Information</h2>
-
</div>
<div class="container">
<hr>
Modified: thrift/site/publish/tutorial/py/index.html
URL: http://svn.apache.org/viewvc/thrift/site/publish/tutorial/py/index.html?rev=1563648&r1=1563647&r2=1563648&view=diff
==============================================================================
--- thrift/site/publish/tutorial/py/index.html (original)
+++ thrift/site/publish/tutorial/py/index.html Sun Feb 2 16:12:33 2014
@@ -68,14 +68,12 @@
<div class="container">
<h2>Python Tutorial</h2>
-<hr>
-
-<h3>Introduction</h3>
+<hr><h3>Introduction</h3>
<p>All Apache Thrift tutorials require that you have:</p>
<ol>
-<li>Built and installed the Apache Thrift Compiler, see <a href="/docs/install/">installing Thrift</a> for more details. </li>
+<li>Built and installed the Apache Thrift Compiler and Libraries, see <a href="/docs/BuildingFromSource/">Building from source</a> for more details. </li>
<li>
<p>Generated the <a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a> file as <a href="/tutorial/">discussed here</a></p>
@@ -83,9 +81,7 @@
</code></pre>
</li>
<li><p>Followed all prerequesets listed </p></li>
-</ol>
-
-<h3>Prerequisites</h3>
+</ol><h3>Prerequisites</h3>
<h3>Client</h3>
@@ -94,7 +90,6 @@
<h3>Server</h3>
<h2>Additional Information</h2>
-
</div>
<div class="container">
<hr>
Modified: thrift/site/publish/tutorial/rb/index.html
URL: http://svn.apache.org/viewvc/thrift/site/publish/tutorial/rb/index.html?rev=1563648&r1=1563647&r2=1563648&view=diff
==============================================================================
--- thrift/site/publish/tutorial/rb/index.html (original)
+++ thrift/site/publish/tutorial/rb/index.html Sun Feb 2 16:12:33 2014
@@ -68,14 +68,12 @@
<div class="container">
<h2>Ruby Tutorial</h2>
-<hr>
-
-<h3>Introduction</h3>
+<hr><h3>Introduction</h3>
<p>All Apache Thrift tutorials require that you have:</p>
<ol>
-<li>Built and installed the Apache Thrift Compiler, see <a href="/docs/install/">installing Thrift</a> for more details. </li>
+<li>Built and installed the Apache Thrift Compiler and Libraries, see <a href="/docs/BuildingFromSource/">Building from source</a> for more details. </li>
<li>
<p>Generated the <a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a> file as <a href="/tutorial/">discussed here</a></p>
@@ -83,9 +81,7 @@
</code></pre>
</li>
<li><p>Followed all prerequesets listed </p></li>
-</ol>
-
-<h3>Prerequisites</h3>
+</ol><h3>Prerequisites</h3>
<h3>Client</h3>
@@ -94,7 +90,6 @@
<h3>Server</h3>
<h2>Additional Information</h2>
-
</div>
<div class="container">
<hr>
Modified: thrift/site/publish/tutorial/st/index.html
URL: http://svn.apache.org/viewvc/thrift/site/publish/tutorial/st/index.html?rev=1563648&r1=1563647&r2=1563648&view=diff
==============================================================================
--- thrift/site/publish/tutorial/st/index.html (original)
+++ thrift/site/publish/tutorial/st/index.html Sun Feb 2 16:12:33 2014
@@ -68,14 +68,12 @@
<div class="container">
<h2>Smalltalk Tutorial</h2>
-<hr>
-
-<h3>Introduction</h3>
+<hr><h3>Introduction</h3>
<p>All Apache Thrift tutorials require that you have:</p>
<ol>
-<li>Built and installed the Apache Thrift Compiler, see <a href="/docs/install/">installing Thrift</a> for more details. </li>
+<li>Built and installed the Apache Thrift Compiler and Libraries, see <a href="/docs/BuildingFromSource/">Building from source</a> for more details. </li>
<li>
<p>Generated the <a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a> file as <a href="/tutorial/">discussed here</a></p>
@@ -83,9 +81,7 @@
</code></pre>
</li>
<li><p>Followed all prerequesets listed </p></li>
-</ol>
-
-<h3>Prerequisites</h3>
+</ol><h3>Prerequisites</h3>
<h3>Client</h3>
@@ -94,7 +90,6 @@
<h3>Server</h3>
<h2>Additional Information</h2>
-
</div>
<div class="container">
<hr>