11from .configcatclient import ConfigCatClient
22from .interfaces import ConfigCatClientException
33from .datagovernance import DataGovernance
4+ from .configcatoptions import ConfigCatOptions
5+ from .pollingmode import PollingMode
46
57
68def create_client (sdk_key , data_governance = DataGovernance .Global ):
@@ -18,7 +20,8 @@ def create_client(sdk_key, data_governance=DataGovernance.Global):
1820
1921def create_client_with_auto_poll (sdk_key , poll_interval_seconds = 60 , max_init_wait_time_seconds = 5 ,
2022 on_configuration_changed_callback = None , config_cache_class = None ,
21- base_url = None , proxies = None , proxy_auth = None , connect_timeout = 10 , read_timeout = 30 ,
23+ base_url = None , proxies = None , proxy_auth = None ,
24+ connect_timeout_seconds = 10 , read_timeout_seconds = 30 ,
2225 flag_overrides = None ,
2326 data_governance = DataGovernance .Global ,
2427 default_user = None ):
@@ -34,9 +37,9 @@ def create_client_with_auto_poll(sdk_key, poll_interval_seconds=60, max_init_wai
3437 :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat
3538 :param proxies: Proxy addresses. e.g. { 'https': 'your_proxy_ip:your_proxy_port' }
3639 :param proxy_auth: Proxy authentication. e.g. HTTPProxyAuth('username', 'password')
37- :param connect_timeout : The number of seconds to wait for the server to make the initial connection
40+ :param connect_timeout_seconds : The number of seconds to wait for the server to make the initial connection
3841 (i.e. completing the TCP connection handshake). Default: 10 seconds.
39- :param read_timeout : The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
42+ :param read_timeout_seconds : The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
4043 :param flag_overrides: An OverrideDataSource implementation used to override feature flags & settings.
4144 :param data_governance:
4245 Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: \n
@@ -46,33 +49,25 @@ def create_client_with_auto_poll(sdk_key, poll_interval_seconds=60, max_init_wai
4649 ConfigCatClient.get_value, ConfigCatClient.get_all_values, etc. methods.
4750 """
4851
49- if sdk_key is None :
50- raise ConfigCatClientException ('SDK Key is required.' )
51-
52- if poll_interval_seconds < 1 :
53- poll_interval_seconds = 1
54-
55- if max_init_wait_time_seconds < 0 :
56- max_init_wait_time_seconds = 0
57-
58- return ConfigCatClient (sdk_key = sdk_key ,
59- poll_interval_seconds = poll_interval_seconds ,
60- max_init_wait_time_seconds = max_init_wait_time_seconds ,
61- on_configuration_changed_callback = on_configuration_changed_callback ,
62- cache_time_to_live_seconds = 0 ,
63- config_cache_class = config_cache_class ,
64- base_url = base_url ,
65- proxies = proxies ,
66- proxy_auth = proxy_auth ,
67- connect_timeout = connect_timeout ,
68- read_timeout = read_timeout ,
69- flag_overrides = flag_overrides ,
70- data_governance = data_governance ,
71- default_user = default_user )
52+ options = ConfigCatOptions (
53+ base_url = base_url ,
54+ polling_mode = PollingMode .auto_poll (auto_poll_interval_seconds = poll_interval_seconds ,
55+ max_init_wait_time_seconds = max_init_wait_time_seconds ,
56+ on_config_changed = on_configuration_changed_callback ),
57+ config_cache = config_cache_class ,
58+ proxies = proxies ,
59+ proxy_auth = proxy_auth ,
60+ connect_timeout_seconds = connect_timeout_seconds ,
61+ read_timeout_seconds = read_timeout_seconds ,
62+ flag_overrides = flag_overrides ,
63+ data_governance = data_governance ,
64+ default_user = default_user )
65+ return ConfigCatClient .get (sdk_key = sdk_key , options = options )
7266
7367
7468def create_client_with_lazy_load (sdk_key , cache_time_to_live_seconds = 60 , config_cache_class = None ,
75- base_url = None , proxies = None , proxy_auth = None , connect_timeout = 10 , read_timeout = 30 ,
69+ base_url = None , proxies = None , proxy_auth = None ,
70+ connect_timeout_seconds = 10 , read_timeout_seconds = 30 ,
7671 flag_overrides = None ,
7772 data_governance = DataGovernance .Global ,
7873 default_user = None ):
@@ -86,9 +81,9 @@ def create_client_with_lazy_load(sdk_key, cache_time_to_live_seconds=60, config_
8681 :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat
8782 :param proxies: Proxy addresses. e.g. { "https": "your_proxy_ip:your_proxy_port" }
8883 :param proxy_auth: Proxy authentication. e.g. HTTPProxyAuth('username', 'password')
89- :param connect_timeout : The number of seconds to wait for the server to make the initial connection
84+ :param connect_timeout_seconds : The number of seconds to wait for the server to make the initial connection
9085 (i.e. completing the TCP connection handshake). Default: 10 seconds.
91- :param read_timeout : The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
86+ :param read_timeout_seconds : The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
9287 :param flag_overrides: An OverrideDataSource implementation used to override feature flags & settings.
9388 :param data_governance:
9489 Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: \n
@@ -98,30 +93,23 @@ def create_client_with_lazy_load(sdk_key, cache_time_to_live_seconds=60, config_
9893 ConfigCatClient.get_value, ConfigCatClient.get_all_values, etc. methods.
9994 """
10095
101- if sdk_key is None :
102- raise ConfigCatClientException ('SDK Key is required.' )
103-
104- if cache_time_to_live_seconds < 1 :
105- cache_time_to_live_seconds = 1
106-
107- return ConfigCatClient (sdk_key = sdk_key ,
108- poll_interval_seconds = 0 ,
109- max_init_wait_time_seconds = 0 ,
110- on_configuration_changed_callback = None ,
111- cache_time_to_live_seconds = cache_time_to_live_seconds ,
112- config_cache_class = config_cache_class ,
113- base_url = base_url ,
114- proxies = proxies ,
115- proxy_auth = proxy_auth ,
116- connect_timeout = connect_timeout ,
117- read_timeout = read_timeout ,
118- flag_overrides = flag_overrides ,
119- data_governance = data_governance ,
120- default_user = default_user )
96+ options = ConfigCatOptions (
97+ base_url = base_url ,
98+ polling_mode = PollingMode .lazy_load (cache_refresh_interval_seconds = cache_time_to_live_seconds ),
99+ config_cache = config_cache_class ,
100+ proxies = proxies ,
101+ proxy_auth = proxy_auth ,
102+ connect_timeout_seconds = connect_timeout_seconds ,
103+ read_timeout_seconds = read_timeout_seconds ,
104+ flag_overrides = flag_overrides ,
105+ data_governance = data_governance ,
106+ default_user = default_user )
107+ return ConfigCatClient .get (sdk_key = sdk_key , options = options )
121108
122109
123110def create_client_with_manual_poll (sdk_key , config_cache_class = None ,
124- base_url = None , proxies = None , proxy_auth = None , connect_timeout = 10 , read_timeout = 30 ,
111+ base_url = None , proxies = None , proxy_auth = None ,
112+ connect_timeout_seconds = 10 , read_timeout_seconds = 30 ,
125113 flag_overrides = None ,
126114 data_governance = DataGovernance .Global ,
127115 default_user = None ):
@@ -134,9 +122,9 @@ def create_client_with_manual_poll(sdk_key, config_cache_class=None,
134122 :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat
135123 :param proxies: Proxy addresses. e.g. { "https": "your_proxy_ip:your_proxy_port" }
136124 :param proxy_auth: Proxy authentication. e.g. HTTPProxyAuth('username', 'password')
137- :param connect_timeout : The number of seconds to wait for the server to make the initial connection
125+ :param connect_timeout_seconds : The number of seconds to wait for the server to make the initial connection
138126 (i.e. completing the TCP connection handshake). Default: 10 seconds.
139- :param read_timeout : The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
127+ :param read_timeout_seconds : The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
140128 :param flag_overrides: An OverrideDataSource implementation used to override feature flags & settings.
141129 :param data_governance:
142130 Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: \n
@@ -146,20 +134,15 @@ def create_client_with_manual_poll(sdk_key, config_cache_class=None,
146134 ConfigCatClient.get_value, ConfigCatClient.get_all_values, etc. methods.
147135 """
148136
149- if sdk_key is None :
150- raise ConfigCatClientException ('SDK Key is required.' )
151-
152- return ConfigCatClient (sdk_key = sdk_key ,
153- poll_interval_seconds = 0 ,
154- max_init_wait_time_seconds = 0 ,
155- on_configuration_changed_callback = None ,
156- cache_time_to_live_seconds = 0 ,
157- config_cache_class = config_cache_class ,
158- base_url = base_url ,
159- proxies = proxies ,
160- proxy_auth = proxy_auth ,
161- connect_timeout = connect_timeout ,
162- read_timeout = read_timeout ,
163- flag_overrides = flag_overrides ,
164- data_governance = data_governance ,
165- default_user = default_user )
137+ options = ConfigCatOptions (
138+ base_url = base_url ,
139+ polling_mode = PollingMode .manual_poll (),
140+ config_cache = config_cache_class ,
141+ proxies = proxies ,
142+ proxy_auth = proxy_auth ,
143+ connect_timeout_seconds = connect_timeout_seconds ,
144+ read_timeout_seconds = read_timeout_seconds ,
145+ flag_overrides = flag_overrides ,
146+ data_governance = data_governance ,
147+ default_user = default_user )
148+ return ConfigCatClient .get (sdk_key = sdk_key , options = options )
0 commit comments