Config parser
chriso opened this issue · 4 comments
It would be great if we could pass around a file which contained the list of nodes and have the library parse it for us:
from clandestined import Cluster, load_nodes
cluster = Cluster(load_nodes('nodes.json'))
It doesn't matter if it uses yaml/json/ini/cfg/whatever, it's just nice having the library handle it for us.
JSON is python std lib compatible, as well as basically every well formed language. so it's definitely the best option.
the only concern might be handling extensions in future, but i think that most things will still maintain a mapping which is basically a hash of ids to hashes containing data.
my only concern is supporting handlers down the line, so that rather than getting just a string, you can obtain a handler to the service you're connecting (Redis/Postgres/Mongo/whatever)
so in that light, it becomes a battle to define a portable format that still allows instantiating connections to backend services.
Guess we can just
import json
with open('nodes.json') as config:
nodes = json.loads(config.read())
cluster = Cluster(nodes)
the target would only be to ever extend the "metadata" section of a nodes configuration.
it may be worth withdrawing RendezvousHash
from the public API for 1.0.0
release, or having it accept a hash of hashes as well.
int the latter case, both Cluster
and RendezvousHash
accept the same Key-Value combinations, but RendezvousHash
just drops zone information on the floor.