summaryrefslogtreecommitdiff
path: root/tutorial/erl
diff options
context:
space:
mode:
authorBryan Duxbury <bryanduxbury@apache.org>2010-08-19 05:06:02 +0000
committerBryan Duxbury <bryanduxbury@apache.org>2010-08-19 05:06:02 +0000
commitd3879f80c6bfb8c60b569ceb9a6235fcdff066a2 (patch)
tree7fdca464c46a47906eec4da069f20a7f90cf12d7 /tutorial/erl
parentd50f347e33abcfc5c4d70bb8d276f3e1951f4e00 (diff)
downloadthrift-d3879f80c6bfb8c60b569ceb9a6235fcdff066a2.tar.gz
THRIFT-599. erl: Don't use unnecessary processes in the Erlang transports and clients
The only user-visible changes are to the client. Every thrift call now returns {NewClient, Result} instead of just Result. Patch: David Reiss (assist to Anthony Molinaro) git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@987018 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tutorial/erl')
-rw-r--r--tutorial/erl/client.erl50
1 files changed, 27 insertions, 23 deletions
diff --git a/tutorial/erl/client.erl b/tutorial/erl/client.erl
index 978033496..adaebe424 100644
--- a/tutorial/erl/client.erl
+++ b/tutorial/erl/client.erl
@@ -29,46 +29,50 @@ p(X) ->
t() ->
Port = 9999,
-
- {ok, Client} = thrift_client:start_link("127.0.0.1",
- Port,
- calculator_thrift),
- thrift_client:call(Client, ping, []),
+ {ok, Client0} = thrift_client_util:new("127.0.0.1",
+ Port,
+ calculator_thrift,
+ []),
+
+ {Client1, {ok, ok}} = thrift_client:call(Client0, ping, []),
io:format("ping~n", []),
- {ok, Sum} = thrift_client:call(Client, add, [1, 1]),
+ {Client2, {ok, Sum}} = thrift_client:call(Client1, add, [1, 1]),
io:format("1+1=~p~n", [Sum]),
- {ok, Sum1} = thrift_client:call(Client, add, [1, 4]),
+ {Client3, {ok, Sum1}} = thrift_client:call(Client2, add, [1, 4]),
io:format("1+4=~p~n", [Sum1]),
Work = #work{op=?tutorial_SUBTRACT,
num1=15,
num2=10},
- {ok, Diff} = thrift_client:call(Client, calculate, [1, Work]),
+ {Client4, {ok, Diff}} = thrift_client:call(Client3, calculate, [1, Work]),
io:format("15-10=~p~n", [Diff]),
- {ok, Log} = thrift_client:call(Client, getStruct, [1]),
+ {Client5, {ok, Log}} = thrift_client:call(Client4, getStruct, [1]),
io:format("Log: ~p~n", [Log]),
- try
- Work1 = #work{op=?tutorial_DIVIDE,
- num1=1,
- num2=0},
- {ok, _Quot} = thrift_client:call(Client, calculate, [2, Work1]),
+ Client6 =
+ try
+ Work1 = #work{op=?tutorial_DIVIDE,
+ num1=1,
+ num2=0},
+ {ClientS1, {ok, _Quot}} = thrift_client:call(Client5, calculate, [2, Work1]),
- io:format("LAME: exception handling is broken~n", [])
- catch
- Z ->
- io:format("Got exception where expecting - the " ++
- "following is NOT a problem!!!~n"),
- p(Z)
- end,
+ io:format("LAME: exception handling is broken~n", []),
+ ClientS1
+ catch
+ throw:{ClientS2, Z} ->
+ io:format("Got exception where expecting - the " ++
+ "following is NOT a problem!!!~n"),
+ p(Z),
+ ClientS2
+ end,
- {ok, ok} = thrift_client:call(Client, zip, []),
+ {Client7, {ok, ok}} = thrift_client:call(Client6, zip, []),
io:format("zip~n", []),
- ok = thrift_client:close(Client),
+ {_Client8, ok} = thrift_client:close(Client7),
ok.