Skip to content

Instantly share code, notes, and snippets.

View ddossot's full-sized avatar
:shipit:
s̴̝̺̫͖̞͛̑͆̀̽̕ḩ̵͌̀͘í̴̝̰͉̒́̐͗p̶̯͍͎͒̿́̈́̕

David Dossot ddossot

:shipit:
s̴̝̺̫͖̞͛̑͆̀̽̕ḩ̵͌̀͘í̴̝̰͉̒́̐͗p̶̯͍͎͒̿́̈́̕
View GitHub Profile
@ddossot
ddossot / mingle_lists.erl
Created March 16, 2010 18:25
Mingle n lists by successively taking elements of each list. The lists don't need to be of the same size.
%% Mingle n lists by successively taking elements of each list. The lists don't need to be of the same size.
%% @spec mingle(ListOfLists::[List::[term()]]) -> Result::[term()]
mingle(ListOfLists) ->
mingle(ListOfLists, []).
mingle([], Result) ->
lists:reverse(Result);
mingle(ListOfLists, Result) ->
{NewListOfLists, NewResult} =
lists:foldl(fun(List, {ListOfListsAcc, ResultAcc}) ->
case List of
// imports omitted for brevity
/**
* A POJO that can add a configured list of file endpoints to the inbound router of a service.
*
* @author <a href="mailto:[email protected]">David Dossot</a>
*/
public class InboundFileEndpointConfigurer implements MuleContextAware {
private MuleContext muleContext;
private Service targetService;
<spring:bean class="InboundFileEndpointConfigurer"
p:targetService-ref="FileJobAcceptor"
p:connector-ref="NonDeletingFileConnector"
p:configuration-ref="MyConfiguration"
init-method="initialize" />
<service name="FileJobAcceptor">
<inbound />
<outbound>
<pass-through-router>
<outbound-endpoint ref="...">
</outbound>
</service>
<service name="load-throttler">
<inbound>
<http:inbound-endpoint address="http://localhost:9500/throttler"
synchronous="false" />
</inbound>
<outbound>
<pass-through-router>
<http:outbound-endpoint address="http://localhost:9600/application"
synchronous="false" />
</pass-through-router>
$ time for (( i = 0 ; i < 10; i++ )); do curl -d "msg$i" http://localhost:9600/application ; done
real 0m10.157s
user 0m0.064s
sys 0m0.048s
$ time for (( i = 0 ; i < 10; i++ )); do curl -d "msg$i" http://localhost:9500/throttler ; done
real 0m0.310s
user 0m0.052s
sys 0m0.020s
<vm:connector name="vmConnector">
<vm:queue-profile persistent="true" maxOutstandingMessages="10000" />
</vm:connector>
...
<service name="persistent-load-throttler-in">
<inbound>
<http:inbound-endpoint address="http://localhost:9500/throttler" synchronous="false" />
</inbound>
<service name="load-throttler">
<inbound>
<http:inbound-endpoint address="http://localhost:9500/throttler"
synchronous="false" />
</inbound>
<outbound>
<pass-through-router>
<http:outbound-endpoint address="http://localhost:9600/application"
synchronous="false" />
</pass-through-router>
$ time for (( i = 0 ; i < 10; i++ )); do curl -d "msg$i" http://localhost:9600/application ; done
real 0m10.157s
user 0m0.064s