hazelcast-python-client
hazelcast-python-client copied to clipboard
Consider separating client construction and cluster connection
Currently HazelcastClient
tries to connect to the Hazelcast cluster during construction. This is unexpected and probably something we shouldn't do in the constructor.
It would be better to separate client instance construction and cluster connection steps. Something along the lines of
hz = HazelcastClient()
hz.connect()
That also gives us the opportunity to assign listeners, etc. after creating the client instance:
hz = HazelcastClient()
hz.add_lifecycle_listener( ... )
# ...
hz.connect()
I like it.
I think adding a connect=True/False
keyword argument could also be a good idea.
This is how pymongo
behaves. Although they default to connect=True
.
https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient
MongoClient(host='localhost', port=27017, document_class=dict, tz_aware=False, connect=True, **kwargs)