summaryrefslogtreecommitdiff
path: root/tutorial/erl
diff options
context:
space:
mode:
authorChristopher Piro <cpiro@apache.org>2007-09-18 06:23:33 +0000
committerChristopher Piro <cpiro@apache.org>2007-09-18 06:23:33 +0000
commit93a0664affc0805d11c9d69ae9989e96f2700842 (patch)
treedaa5392f33fe1daf9f129588bdc7d74a659e6221 /tutorial/erl
parent0f6cc29f7237e4d2b1b757848e27ccc3efdbc513 (diff)
downloadthrift-93a0664affc0805d11c9d69ae9989e96f2700842.tar.gz
[thrift] spruce up Erlang binding for tonight's release
Summary: * got rid of most of the otp_base jonx ... save that for a future release unfortunately * cleaned up the tutorial server, added -erl to tutorial.thrift's shebang * made better README and TODO Test Plan: checked out a copy, read my directions, built and ran the tutorial, and pretended that it didn't blow git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665273 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tutorial/erl')
-rw-r--r--tutorial/erl/ErlClient.rb49
-rw-r--r--tutorial/erl/server.erl4
-rwxr-xr-xtutorial/erl/server.sh18
3 files changed, 20 insertions, 51 deletions
diff --git a/tutorial/erl/ErlClient.rb b/tutorial/erl/ErlClient.rb
deleted file mode 100644
index bcf130094..000000000
--- a/tutorial/erl/ErlClient.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.push('../gen-rb')
-
-require 'thrift/transport/tsocket'
-require 'thrift/protocol/tbinaryprotocol'
-
-require 'Calculator'
-
-begin
-
- transport = TBufferedTransport.new(TSocket.new('localhost', 9090))
- protocol = TBinaryProtocol.new(transport)
- client = Calculator::Client.new(protocol)
-
- transport.open()
-
- client.ping()
- print "ping()\n"
-
- sum = client.add(1,1)
- print "1+1=", sum, "\n"
-
- work = Work.new()
-
- begin
- work.op = Operation::DIVIDE
- work.num1 = 1
- work.num2 = 0
- quot = client.calculate(1, work)
- puts "Whoa, we can divide by 0 now?"
- rescue InvalidOperation => io
- print "InvalidOperation: ", io.why, "\n"
- end
-
- work.op = Operation::SUBTRACT
- work.num1 = 15
- work.num2 = 10
- diff = client.calculate(1, work)
- print "15-10=", diff, "\n"
-
- log = client.getStruct(1)
- print "Log: ", log.value, "\n"
-
- transport.close()
-
-rescue TException => tx
- print 'TException: ', tx.message, "\n"
-end
diff --git a/tutorial/erl/server.erl b/tutorial/erl/server.erl
index 2a44e1d05..ab2b04046 100644
--- a/tutorial/erl/server.erl
+++ b/tutorial/erl/server.erl
@@ -8,7 +8,7 @@
-include("server/tErlServer.hrl").
-include("transport/tErlAcceptor.hrl").
--include("calculator.hrl").
+-include("calculator_thrift.hrl").
-export([start/0, start/1, stop/1, ping/0, add/2, calculate/2, getStruct/1, zip/0]).
@@ -62,7 +62,7 @@ start(Port) ->
}]),
Handler = ?MODULE,
- Processor = calculator,
+ Processor = calculator_thrift,
TF = tBufferedTransportFactory:new(),
PF = tBinaryProtocolFactory:new(),
diff --git a/tutorial/erl/server.sh b/tutorial/erl/server.sh
new file mode 100755
index 000000000..a76352693
--- /dev/null
+++ b/tutorial/erl/server.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+ERL_THRIFT=../../lib/erl
+
+if ! [ -d ${ERL_THRIFT}/ebin ]; then
+ echo "Please build the Thrift library by running \`make' in ${ERL_THRIFT}"
+ exit 1
+fi
+
+if ! [ -d ../gen-erl ]; then
+ echo "Please run thrift first to generate ../gen-erl/"
+ exit 1
+fi
+
+
+erlc -I ${ERL_THRIFT}/include -I ../gen-erl -o ../gen-erl ../gen-erl/*.erl &&
+ erlc -I ${ERL_THRIFT}/include -I ../gen-erl *.erl &&
+ erl +K true -pa ${ERL_THRIFT}/ebin -pa ../gen-erl