From: David Reiss Date: Wed, 11 Jun 2008 01:13:33 +0000 (+0000) Subject: add thrift_client:cast X-Git-Tag: 0.2.0~687 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=a2f45970bb17e4aef9a578a15fdd176534d48581;p=common%2Fthrift.git add thrift_client:cast git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666475 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/alterl/src/thrift_client.erl b/lib/alterl/src/thrift_client.erl index d6508bb2..802c0096 100644 --- a/lib/alterl/src/thrift_client.erl +++ b/lib/alterl/src/thrift_client.erl @@ -93,6 +93,10 @@ call(Client, Function, Args) {exception, Exception} -> throw(Exception) end. +cast(Client, Function, Args) + when is_pid(Client), is_atom(Function), is_list(Args) -> + gen_server:cast(Client, {call, Function, Args}). + %% Sends a function call but does not read the result. This is useful %% if you're trying to log non-async function calls to write-only %% transports like thrift_disk_log_transport. @@ -100,7 +104,6 @@ send_call(Client, Function, Args) when is_pid(Client), is_atom(Function), is_list(Args) -> gen_server:call(Client, {send_call, Function, Args}). - close(Client) when is_pid(Client) -> gen_server:cast(Client, close). @@ -180,6 +183,20 @@ catch_function_exceptions(Fun, Service) -> %% {stop, Reason, State} %% Description: Handling cast messages %%-------------------------------------------------------------------- +handle_cast({call, Function, Args}, State = #state{service = Service, + protocol = Protocol, + seqid = SeqId}) -> + _Result = + try + ok = send_function_call(State, Function, Args), + receive_function_result(State, Function) + catch + Class:Reason -> + error_logger:error_msg("error ignored in handle_cast({cast,...},...): ~p:~p~n", [Class, Reason]) + end, + + {noreply, State}; + handle_cast(close, State=#state{protocol = Protocol}) -> %% error_logger:info_msg("thrift_client ~p received close", [self()]), {stop,normal,State};