basho / cuttlefish

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

aliases #67

Closed Licenser closed 10 years ago

Licenser commented 10 years ago

I found it to be a commone sep to do something like this:

{mapping, "data_dir", "riak_core.platform_data_dir",
 [{default, "{{platform_data_dir}}"},
  {datatype, string}]}.

{translation,
 "fifo_db.db_path",
 fun(Conf) ->
         cuttlefish_util:conf_get_value("data_dir", Conf)
 end
}.

{translation,
 "leveldb.data_root",
 fun(Conf) ->
         cuttlefish_util:conf_get_value("data_dir", Conf)
 end
}.

{translation,
 "hanoidb.data_root",
 fun(Conf) ->
         cuttlefish_util:conf_get_value("data_dir", Conf)
 end
}.

{translation,
 "bitcask.data_root",
 fun(Conf) ->
         cuttlefish_util:conf_get_value("data_dir", Conf)
 end
}.

aka hide the detailed setting under a simplified name for a system. So what would be great is if there would be something like {alias, "hanoidb.data_root"} which would then act as a 'default' for hanoidb.data_root (as example).

So this would simplify the above code to:

{mapping, "data_dir", "riak_core.platform_data_dir",
 [{default, "{{platform_data_dir}}"},
  {datatype, string},
  {alias, "fifo_db.db_path"},
  {alias, "leveldb.data_root"},
  {alias, "hanoidb.data_root"},
  {alias, "bitcask.data_root"}]}.

which is kind of sweet ;)

joedevivo commented 10 years ago

I'm going to mull this over the weekend. I think it (or something similar) will solve some problems I've also had. Part of the mulling will be trying to remember what those problems were.

Licenser commented 10 years ago

mull away! If you want I can make a PR for this too but I wanted to discuss it before investing more time then just coming up with crazy stuff ;)

joedevivo commented 10 years ago

This is covered now with the little publicized "right hand substitutions" feature. It would work like this:

{mapping, "data_dir", "riak_core.platform_data_dir",
 [{default, "{{platform_data_dir}}"},
  {datatype, directory}]}.

{mapping, "hanoi.data_root", "hanoidb.data_root",
 [{default, "#(data_dir)/hanoi"},
  {datatype, directory}]}.

then you could also override in your .conf file like this:

data_dir = /wherever
hanoi.data_root = #(data_dir)/some_other_hanoi_path