[ 
https://issues.apache.org/jira/browse/THRIFT-1236?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Anthony Molinaro resolved THRIFT-1236.
--------------------------------------

    Resolution: Fixed

This client is useful, and has no impact on other code, so committing.  We can 
probably consider it experimental for 0.7 release (once 0.7 is out, we'll use 
it in our production setup at OpenX, and then we can call it official).

> Erlang Reconnecting Thrift Client
> ---------------------------------
>
>                 Key: THRIFT-1236
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1236
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Erlang - Library
>    Affects Versions: 0.6.1
>            Reporter: Joel Meyer
>            Assignee: Anthony Molinaro
>             Fix For: 0.7
>
>         Attachments: thrift_reconnecting_client.erl
>
>
> Anthony suggested I contribute this module. It's a reconnecting thrift client 
> that I wrote for use at OpenX. I modified the source to remove some internal 
> dependencies and added the Apache License. I also did some basic smoke 
> testing on this version (the internal version has been in production for a 
> while). This does not re-queue a failed request, it returns a failure with 
> the underlying error - this allows applications to record the failure and 
> define its own re-queue semantics.
> {code:title=example.erl}
> Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:2:2] [rq:2] 
> [async-threads:0] [hipe] [kernel-poll:false]
> Eshell V5.8.4  (abort with ^G)
> 1> %% Helper funs specific to the service
> 1> MakeFreq = fun( IntCnt, IntMins, IntBits, Key ) -> { freqId, { freqType, 
> IntCnt, IntMins, IntBits }, Key } end.
> #Fun<erl_eval.4.88154533>
> 2> MakeRange = fun( FreqId, Duration ) -> { freqCountRange, FreqId, Duration 
> } end.
> #Fun<erl_eval.12.107821302>
> 3> FreqIncr( FreqConn1, [ Freq1 ] ).
> * 1: variable 'FreqIncr' is unbound
> 4> FreqCount( FreqConn1, [ MakeRange( Freq1, 10 ) ] ).
> * 1: variable 'FreqCount' is unbound
> 5> FreqDelete( FreqConn1, [ Freq1 ] ).
> * 1: variable 'FreqDelete' is unbound
> 6> 
> 6> %% Helper funs for calling the service
> 6> FreqCount  = fun( Pid, Ranges  ) -> thrift_reconnecting_client:call( Pid, 
> count_all, [ Ranges ] ) end.
> #Fun<erl_eval.12.107821302>
> 7> FreqIncr   = fun( Pid, FreqIds ) -> thrift_reconnecting_client:call( Pid, 
> increment_all, [ FreqIds ] ) end.
> #Fun<erl_eval.12.107821302>
> 8> FreqDelete = fun( Pid, FreqIds ) -> thrift_reconnecting_client:call( Pid, 
> delete_all, [ FreqIds ] ) end.
> #Fun<erl_eval.12.107821302>
> 9> FreqStats  = fun( Pid )          -> thrift_reconnecting_client:get_stats( 
> Pid ) end.
> #Fun<erl_eval.6.80247286>
> 10> 
> 10> { ok, FreqConn } = thrift_reconnecting_client:start_link( 
> "qa-ox3-freq-xv-01.xv.dc.openx.org", 12422, frequencyService_thrift, [ { 
> framed, true } ], 250, 60 * 1000 ).
> {ok,<0.42.0>}
> 11> Freq1 = MakeFreq( 4, 5, 3, "delete_test1" ).
> {freqId,{freqType,4,5,3},"delete_test1"}
> 12> FreqIncr( FreqConn, [ Freq1 ] ).
> {ok,ok}
> 13> FreqCount( FreqConn, [ MakeRange( Freq1, 10 ) ] ).
> {ok,[{freqCount,1,21840142}]}
> 14> FreqStats( FreqConn ).
> [{"frequencyService_thrift_increment_all_success",1,79048},
>  {"frequencyService_thrift_count_all_success",1,77429}]
> 15> FreqIncr( FreqConn, [ Freq1 ] ).
> {ok,ok}
> 16> FreqCount( FreqConn, [ MakeRange( Freq1, 10 ) ] ).
> {ok,[{freqCount,2,21840142}]}
> 17> FreqStats( FreqConn ).
> [{"frequencyService_thrift_increment_all_success",2,146781},
>  {"frequencyService_thrift_count_all_success",2,145807}]
> 18> %% Restart service
> 18> 
> 18> FreqIncr( FreqConn, [ Freq1 ] ).
> {'EXIT',{{case_clause,{error,closed}},
>          [{thrift_client,read_result,3},
>           {thrift_reconnecting_client,handle_call,3},
>           {gen_server,handle_msg,5},
>           {proc_lib,init_p_do_apply,3}]}}
> 19> FreqCount( FreqConn, [ MakeRange( Freq1, 10 ) ] ).
> {ok,[{freqCount,0,0}]}
> 20> FreqStats( FreqConn ).
> [{"frequencyService_thrift_increment_all_success",2,146781},
>  {"frequencyService_thrift_count_all_success",3,272716},
>  {"frequencyService_thrift_increment_all_error",1,375}]
> 21>                                                   
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to