hazelcast-python-client icon indicating copy to clipboard operation
hazelcast-python-client copied to clipboard

Consider separating client construction and cluster connection

Open yuce opened this issue 3 years ago • 1 comments

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()

yuce avatar Feb 03 '21 00:02 yuce

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)

Kilo59 avatar Feb 03 '21 20:02 Kilo59