]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/tutorial/erl/client.erl
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / tutorial / erl / client.erl
CommitLineData
f67539c2
TL
1%%
2%% Licensed to the Apache Software Foundation (ASF) under one
3%% or more contributor license agreements. See the NOTICE file
4%% distributed with this work for additional information
5%% regarding copyright ownership. The ASF licenses this file
6%% to you under the Apache License, Version 2.0 (the
7%% "License"); you may not use this file except in compliance
8%% with the License. You may obtain a copy of the License at
9%%
10%% http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing,
13%% software distributed under the License is distributed on an
14%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15%% KIND, either express or implied. See the License for the
16%% specific language governing permissions and limitations
17%% under the License.
18%%
19
20-module(client).
21
22-include("calculator_thrift.hrl").
23
24-export([t/0]).
25
26p(X) ->
27 io:format("~p~n", [X]),
28 ok.
29
30t() ->
31 Port = 9090,
32
33 {ok, Client0} = thrift_client_util:new("127.0.0.1",
34 Port,
35 calculator_thrift,
36 []),
37
38 {Client1, {ok, ok}} = thrift_client:call(Client0, ping, []),
39 io:format("ping~n", []),
40
41 {Client2, {ok, Sum}} = thrift_client:call(Client1, add, [1, 1]),
42 io:format("1+1=~p~n", [Sum]),
43
44 {Client3, {ok, Sum1}} = thrift_client:call(Client2, add, [1, 4]),
45 io:format("1+4=~p~n", [Sum1]),
46
47 Work = #'Work'{op=?TUTORIAL_OPERATION_SUBTRACT,
48 num1=15,
49 num2=10},
50 {Client4, {ok, Diff}} = thrift_client:call(Client3, calculate, [1, Work]),
51 io:format("15-10=~p~n", [Diff]),
52
53 {Client5, {ok, Log}} = thrift_client:call(Client4, getStruct, [1]),
54 io:format("Log: ~p~n", [Log]),
55
56 Client6 =
57 try
58 Work1 = #'Work'{op=?TUTORIAL_OPERATION_DIVIDE,
59 num1=1,
60 num2=0},
61 {ClientS1, {ok, _Quot}} = thrift_client:call(Client5, calculate, [2, Work1]),
62
63 io:format("LAME: exception handling is broken~n", []),
64 ClientS1
65 catch
66 throw:{ClientS2, Z} ->
67 io:format("Got exception where expecting - the " ++
68 "following is NOT a problem!!!~n"),
69 p(Z),
70 ClientS2
71 end,
72
73
74 {Client7, {ok, ok}} = thrift_client:call(Client6, zip, []),
75 io:format("zip~n", []),
76
77 {_Client8, ok} = thrift_client:close(Client7),
78 ok.