Skip to content

Commit 02a1bfd

Browse files
hadicanAbdulhadi Celenlioglu
and
Abdulhadi Celenlioglu
authored
add stats_interval_in_seconds parameter to the client configuration (#248)
Co-authored-by: Abdulhadi Celenlioglu <[email protected]>
1 parent f973c30 commit 02a1bfd

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

pulsar/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ def __init__(self, service_url,
482482
message_listener_threads=1,
483483
concurrent_lookup_requests=50000,
484484
log_conf_file_path=None,
485+
stats_interval_in_seconds=600,
485486
use_tls=False,
486487
tls_trust_certs_file_path=None,
487488
tls_allow_insecure_connection=False,
@@ -520,6 +521,9 @@ def __init__(self, service_url,
520521
log_conf_file_path: str, optional
521522
This parameter is deprecated and makes no effect. It's retained only for compatibility.
522523
Use `logger` to customize a logger.
524+
stats_interval_in_seconds: int, default=600
525+
Set the interval between each stats information update. Stats are printed and/or
526+
passed to the statistics listener at this interval. Set to 0 to disable stats collection.
523527
use_tls: bool, default=False
524528
Configure whether to use TLS encryption on the connection. This setting is deprecated.
525529
TLS will be automatically enabled if the ``serviceUrl`` is set to ``pulsar+ssl://`` or ``https://``
@@ -560,6 +564,7 @@ def __init__(self, service_url,
560564
_check_type(int, message_listener_threads, 'message_listener_threads')
561565
_check_type(int, concurrent_lookup_requests, 'concurrent_lookup_requests')
562566
_check_type_or_none(str, log_conf_file_path, 'log_conf_file_path')
567+
_check_type(int, stats_interval_in_seconds, 'stats_interval_in_seconds')
563568
_check_type(bool, use_tls, 'use_tls')
564569
_check_type_or_none(str, tls_trust_certs_file_path, 'tls_trust_certs_file_path')
565570
_check_type(bool, tls_allow_insecure_connection, 'tls_allow_insecure_connection')
@@ -574,6 +579,7 @@ def __init__(self, service_url,
574579
conf.io_threads(io_threads)
575580
conf.message_listener_threads(message_listener_threads)
576581
conf.concurrent_lookup_requests(concurrent_lookup_requests)
582+
conf.stats_interval_in_seconds(stats_interval_in_seconds)
577583

578584
if isinstance(logger, logging.Logger):
579585
conf.set_logger(self._prepare_logger(logger))

src/config.cc

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ void export_config(py::module_& m) {
157157
.def("concurrent_lookup_requests", &ClientConfiguration::getConcurrentLookupRequest)
158158
.def("concurrent_lookup_requests", &ClientConfiguration::setConcurrentLookupRequest,
159159
return_value_policy::reference)
160+
.def("stats_interval_in_seconds", &ClientConfiguration::getStatsIntervalInSeconds)
161+
.def("stats_interval_in_seconds", &ClientConfiguration::setStatsIntervalInSeconds,
162+
return_value_policy::reference)
160163
.def("use_tls", &ClientConfiguration::isUseTls)
161164
.def("use_tls", &ClientConfiguration::setUseTls, return_value_policy::reference)
162165
.def("tls_trust_certs_file_path", &ClientConfiguration::getTlsTrustCertsFilePath,

tests/pulsar_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ def test_client_argument_errors(self):
828828
self._check_value_error(lambda: Client(None))
829829
self._check_value_error(lambda: Client(self.serviceUrl, authentication="test"))
830830
self._check_value_error(lambda: Client(self.serviceUrl, operation_timeout_seconds="test"))
831+
self._check_value_error(lambda: Client(self.serviceUrl, stats_interval_in_seconds="test"))
831832
self._check_value_error(lambda: Client(self.serviceUrl, io_threads="test"))
832833
self._check_value_error(lambda: Client(self.serviceUrl, message_listener_threads="test"))
833834
self._check_value_error(lambda: Client(self.serviceUrl, concurrent_lookup_requests="test"))

0 commit comments

Comments
 (0)