Even Simpler Queue Service (ESQS)
Like a part of my Erlang study, I decided to code a pure-man queues management service, similar to Amazon SQS – Even Simpler Queue Service (or Erlang SQS you decide ;) ). For now it’s just one file qserver.erl , but i hope to make it better. First I based my code on OTP ( gen_server ), but after this decided to write it from scratch. Lessons learned:
- access to the processes by name, not by Pid is more human friendly
- implement the whole API with simple cast (async) and call (sync) messages
- one function with guards (do_q) is maybe better than several functions with different names
- pg2 gave me better name service, then global:register/unreister
Usage:
Erlang (BEAM) emulator version 5.5.3 [source] [async-threads:0] [hipe] [kernel-poll:false] 1> c(qserver). {ok,qserver} 2> qserver:start('aa'). {ok,<0.38.0>} 3> qserver:start('bb'). {ok,<0.40.0>} 4> qserver:listq(). [bb,aa] 5> qserver:inq('aa',123). {ok,123} 6> qserver:lenq('aa'). 1 7> qserver:inq('aa',[1,2,3]). {ok,[1,2,3]} 8> qserver:revq('aa'). ok 9> qserver:outq('aa'). [1,2,3] 10> qserver:outq('aa'). 123 11> qserver:outq('aa'). ** exited: empty ** 12> qserver:stop('aa'). ok 13> qserver:outq('aa'). {oops,{no_such_group,aa}}
There is still a lot to be done - data exchange with the queues (i want to use UBF for data transport format), more robust name service (pg2 is based on gen_server, so if the node with the database die, all names will be lost) - gen_server_cluster based , ACL to the queues etc.
Other Activities:
- There is no enough time for real blogging, so I just pasting random stuff on ThouTr , my thumblog
- Finally made a ‘front page’ for zhekov.net - (c) KISS ;) , acts like a portal to all my web sites
- Started using Mercurial for my personal development - distributed, svn-like commands, coming with web frontend by default (but CGI only = pretty slow)