__ __
|__) /\ |\/| /__` /\ \ /
| \ /~~\ | | .__/ /~~\ |
Named after one of the [famous] 1 Scottish watchmaker, ramsay
aims
to simplify handling of time values in your Erlang applications.
Yes. And very useful!
Almost all Erlang applications have to deal with time values in one way or another. For example, here's a bit from [Riak] 2 configuration file:
{default_bucket_props, [
{n_val, 3},
{gossip_interval, 60000},
{last_write_wins, false},
]}
Although the unit of gossip_interval
is documented on [Riak Wiki] 2,
it's hard to tell what is it, just looking at the configuration file.
Of course, one way of dealing with this is by having a convention; for
example you might decide that all time values in your project are in
milliseconds. Obviously that doesn't work for people not familiar with
the convention; ramsay
solves the readability problem by using tagged
values:
{default_bucket_props, [
{n_val,3},
{gossip_interval, {minutes, 1}},
{last_write_wins, false},
]}
Neat, huh? here's how this looks on the Erlang side:
start([]) ->
RawGossipInterval = proplists:get_value(gossip_interval,
DefaultBucketProps)
{{milli, seconds}, GossipInterval} = ramsay:measure(GossipInterval,
{milli, seconds})
%% ... more code here