-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
Config
classes to public API [API-1280] (#521)
* Convert `Config` classes to public API These were converted into private classes during the 4.0 migration, as we were only supporting keyword arguments for the client configuration. However, that led to a poor user experience, as we had to use `**kwargs`, instead of listing all the configuration elements in the client constructor. (IDEs become painfully slow once we list all keyword arguments, as there are too many of them) The solution to this problem is to make the Config classes public API and make the client able to use it directly. ```python config = Config() config.cluster_name = "dev2" client = HazelcastClient(config) ``` We provide full type hints for config elements. * bump the client version used in tests * address review comments * shutdown clients in teardown method
- Loading branch information
Showing
27 changed files
with
1,936 additions
and
1,212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ API Documentation | |
|
||
aggregator | ||
cluster | ||
config | ||
core | ||
cp | ||
errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
Configuration Overview | ||
====================== | ||
|
||
For configuration of the Hazelcast Python client, just pass the keyword | ||
arguments to the client to configure the desired aspects. An example is | ||
shown below. | ||
The client can be configured either by keyword arguments or by a configuration | ||
object. | ||
|
||
Keyword Arguments Configuration | ||
------------------------------- | ||
|
||
It is possible to pass keyword arguments directly to the client's constructor | ||
to configure desired aspects of the client. | ||
|
||
The keyword argument names must be valid property names of the | ||
:class:`hazelcast.config.Config` class with valid values. | ||
|
||
.. code:: python | ||
client = hazelcast.HazelcastClient( | ||
cluster_members=["127.0.0.1:5701"] | ||
from hazelcast import HazelcastClient | ||
client = HazelcastClient( | ||
cluster_name="a-cluster", | ||
cluster_members=["127.0.0.1:5701"], | ||
) | ||
See the API documentation of :class:`hazelcast.client.HazelcastClient` | ||
for details. | ||
Using a Configuration Object | ||
---------------------------- | ||
|
||
Alternatively, you can create a configuration object, and pass it to the client | ||
as its only argument. | ||
|
||
This way might provide better user experience as it provides hints for the | ||
configuration option names and their types. | ||
|
||
.. code:: python | ||
from hazelcast import HazelcastClient | ||
from hazelcast.config import Config | ||
config = Config() | ||
config.cluster_name = "a-cluster" | ||
config.cluster_members = ["127.0.0.1:5701"] | ||
client = HazelcastClient(config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,7 @@ Features | |
:hidden: | ||
|
||
client | ||
config | ||
api/modules | ||
getting_started | ||
features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from hazelcast import HazelcastClient | ||
|
||
client = HazelcastClient( | ||
cluster_name="a-cluster", | ||
cluster_members=["10.212.1.132:5701"], | ||
ssl_enabled=True, | ||
near_caches={ | ||
"a-map": { | ||
"time_to_live": 120, | ||
"max_idle": 60, | ||
} | ||
}, | ||
) | ||
|
||
# Do something with the client | ||
|
||
client.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from hazelcast import HazelcastClient | ||
from hazelcast.config import Config, NearCacheConfig | ||
|
||
config = Config() | ||
config.cluster_name = "a-cluster" | ||
config.cluster_members = ["10.212.1.132:5701"] | ||
config.ssl_enabled = True | ||
|
||
near_cache_config = NearCacheConfig() | ||
near_cache_config.time_to_live = 120 | ||
near_cache_config.max_idle = 60 | ||
|
||
config.near_caches = { | ||
"a-map": near_cache_config, | ||
} | ||
|
||
client = HazelcastClient(config) | ||
|
||
# Do something with the client | ||
|
||
client.shutdown() |
Oops, something went wrong.