Skip to content

HollyBrolly/ramsay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 __              __
|__)  /\   |\/| /__`  /\  \ /
|  \ /~~\  |  | .__/ /~~\  |

Named after one of the [famous] 1 Scottish watchmaker, ramsay aims to simplify handling of time values in your Erlang applications.

Is it any good? Build Status

Yes. And very useful!

Why do I need it?

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

About

Tagged time manipulation for Erlang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages