If you are using multiple nodes you would have those nodes operate as
independent services, and you would not spawn anything directly on
them typically. As far as which node to use, with any scheme, you can
either come up with an straightforward algorithmic load balancing
scheme like round robin, you track load and push intelligently, or
have a pull model where workers pull when they are ready. If the work
required for these messages is rather uniform across the set of
messages then the round-robin approach works nicely. If not, then you
need something more complex, either pull or push.
Not sure if this helps.
Cheers,
Martin
--
Martin Logan
Erlang & OTP in Action (Manning) http://manning.com/logan
http://twitter.com/martinjlogan
http://erlware.org
What is the difference between io:fwrite and io:format? When would I use one over the other?
Thanks,
LRP
--io.erl--
fwrite(Format) ->
format(Format).
fwrite(Format, Args) ->
format(Format, Args).
--
I never think to look at source. I'll have to develop the habit.
All the best,
Lloyd
Cheers,
Martin
I'm trying to convert Erlang DateTime format: {Year, Month, Day}{Hour, Minute, Second} to RFC 2616 DateString format: Sun, 06 Nov 1994 08:49:37
I'd like to be able to convert the DateString back to Erlang DateTime using httpd_util:convert_request_date(DateString).
But note if day-of-month, hour, minute, or second are single digit, they need to be of form "0n"; e.g. 01, 02, etc.
So, I have a single digit integer, say 5. But I can't figure out how to display it as "05" in io:format.
~2.1.0w will do it, but fails if the integer has two digits, say 22.
And at this point I'm lost.
Why am I doing this? I want DateString to be easily readable by humans. But I want to be able to sort by DateTimes.
Can anyone help me light the darkness?
Or maybe there's a better way to solve the problem altogether?
Many thanks,
LRP
5> io:format("~2.10.0b~n",[3]).
03
ok
6> io:format("~2.10.0b~n",[23]).
23
ok
7> io:format("~2.10.0b~n",[233]).
**
ok
That help?
Barry Nicholson
Thank you, Barry
I had a similar need awhile ago. I borrowed the implementation in yaws.
Sent from my Android phone.
On Jan 26, 2011 1:45 PM, <ll...@writersglen.com> wrote:
Exactly what I needed!
Thank you, Barry
-----Original Message-----
From: "Barry Nicholson" <b.nic...@niceng.com>
Sent: Wednesday, Januar...
Well, it took your help and an hour or so of flailing, but I finally got this to work:
I have this function in the books.erl:
this_second() ->
% Generate date string in RFC 2616 format
{Today, This_Minute} = calendar:universal_time(),
{Year, Month, DOM} = Today,
{Hour, Minute, Second} = This_Minute,
DOW = calendar:day_of_the_week(Year, Month, DOM),
Day = httpd_util:day(DOW),
M = httpd_util:month(Month),
lists:flatten(io_lib:format("~s, ~2.10.0b ~s ~p ~2.10.0b:~2.10.0b:~2.10.0b", [Day,DOM,M,Year,Hour,Minute,Second])).
books:this_second() gives me a human readable date string:
3> books:this_second().
"Wed, 26 Jan 2011 20:37:48"
And I can convert the date string back to erlang DateTime thus:
4> httpd_util:convert_request_date(books:this_second()).
{{2011,1,26},{20,26,53}}
Given the Erlang DataTime format, I can compare dates:
5> A = httpd_util:convert_request_date(books:this_second()).
{{2011,1,26},{20,36,12}}
6> B = httpd_util:convert_request_date(books:this_second()).
{{2011,1,26},{20,36,46}}
7> A < B.
true
8> A == B.
false
9> A > B.
false
Hope this function is useful to others.
So, thanks again, Barry.
LRP
-----Original Message-----
From: "Barry Nicholson" <b.nic...@niceng.com>
Sent: Wednesday, January 26, 2011 12:38pm
To: erlan...@googlegroups.com
Subject: Re: Converting integers to strings
I'd like to run eDocs on Zotonic source code. If, working from the Zotonic directory /home/zotonic/zotonic/src, I pattern my call on the example on page 130 in Erlang and OTP in Action, e.g.:
edoc:application(zotonic, ".", [])
I get a page full of errors.
Is it likely that these errors result from:
1) The way I'm calling the function?
2) The Zotonic source files?
3) The directory structure of the Zotonic application?
If I try to run edoc:files/2 based on a single Zotonic file I get:
1> edoc:files(["z_string.erl"],[]).
./z_string.erl, in module header: at line 3: warning: tag @date not recognized.
./z_string.erl, function replace/3: at line 591: tag @copyright not allowed here.
edoc: skipping source file './z_string.erl': {'EXIT',error}.
edoc: error in doclet 'edoc_doclet': {'EXIT',error}.
** exception exit: error
in function edoc_lib:run_plugin/5
Here, again, I'm not sure if the error is due to the way I'm calling edoc:files/2 or in the source file itself.
In short, edoc is rather baffling to me due to the lack of clear confidence-building examples.
Can anyone help me climb over this speed bump in my learning curve?
Many thanks,
LRP
*********************************************
My books: Available through Amazon
or by request from your favorite bookstore
Freein' Pancho
Aya Takeo
Websites:
freeinpancho.com
ayatakeo.com
vol1.ayatakeo.com
**********************************************
--