basho / cuttlefish

never lose your childlike sense of wonder baby cuttlefish, promise me?
Apache License 2.0
205 stars 124 forks source link

Extended datatypes #89

Closed joedevivo closed 10 years ago

joedevivo commented 10 years ago

This one's for you @evanmcc and @jtuple

Now, when writing a schema, you can add multiple datatypes. Here's how it works:

In a mapping, {datatype, Type} still works as it used to, but if you want, you can replace Type with a List of types.

Example: anti_entropy.expire

{mapping, "anti_entropy.expire", "riak_kv.anti_entropy.expire", [
    {datatype, [{duration, ms}, {atom, never}]}
]}.

now if you set something like anti_entropy.expire = right_away it will try converting "right_away" into a duration first. When that doesn't work, it'll try converting it to an atom and then compare to 'never'. Only if these all fail will it produce an error, and the first one to pass is the one it uses.

You can put any datatype that currently exists, and I've added a few more. These extended types are single instances of a type, like {atom, never}, which only allows the atom 'never'.

I hope that makes sense. Better documentation for this will come next week on the cuttlefish wiki.

seancribbs commented 10 years ago

Codez seem fine, nice unit tests too. @evanmcc has promised to try it out on a schema.

evanmcc commented 10 years ago

testing with fsm_limit = 50000 | undefined works as expected. will drop a pr for that today.

fwiw I did get this warning on startup:

12:35:27.563 [warning] cuttlefish_util:conf_get_value/2 has been deprecated. use cuttlefish:conf_get/2
config is OK

otherwise, works great, thanks!

joedevivo commented 10 years ago

@evanmcc you might be working with an older schema. I replaced all those function calls this week in each repo.

seancribbs commented 10 years ago

:+1: merge away