From 4747c39ce1daa94d47de4d7245daed55574a8f09 Mon Sep 17 00:00:00 2001 From: Rory Schadler <48921090+roryschadler@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:40:57 -0500 Subject: [PATCH] Expose Get/Set Listener Name in C API --- include/pulsar/c/client_configuration.h | 5 +++++ lib/c/c_ClientConfiguration.cc | 9 +++++++++ tests/c/c_ClientConfigurationTest.cc | 3 +++ 3 files changed, 17 insertions(+) diff --git a/include/pulsar/c/client_configuration.h b/include/pulsar/c/client_configuration.h index 90a29a61..7ff5dcb7 100644 --- a/include/pulsar/c/client_configuration.h +++ b/include/pulsar/c/client_configuration.h @@ -187,6 +187,11 @@ PULSAR_PUBLIC int pulsar_client_configuration_is_validate_hostname(pulsar_client PULSAR_PUBLIC void pulsar_client_configuration_set_validate_hostname(pulsar_client_configuration_t *conf, int validateHostName); +PULSAR_PUBLIC void pulsar_client_configuration_set_listener_name(pulsar_client_configuration_t *conf, + const char *listenerName); + +PULSAR_PUBLIC const char *pulsar_client_configuration_get_listener_name(pulsar_client_configuration_t *conf); + /* * Get the stats interval set in the client. */ diff --git a/lib/c/c_ClientConfiguration.cc b/lib/c/c_ClientConfiguration.cc index ef19f3ac..96a1bf7b 100644 --- a/lib/c/c_ClientConfiguration.cc +++ b/lib/c/c_ClientConfiguration.cc @@ -189,3 +189,12 @@ void pulsar_client_configuration_set_memory_limit(pulsar_client_configuration_t unsigned long long pulsar_client_configuration_get_memory_limit(pulsar_client_configuration_t *conf) { return conf->conf.getMemoryLimit(); } + +void pulsar_client_configuration_set_listener_name(pulsar_client_configuration_t *conf, + const char *listenerName) { + conf->conf.setListenerName(listenerName); +} + +const char *pulsar_client_configuration_get_listener_name(pulsar_client_configuration_t *conf) { + return conf->conf.getListenerName().c_str(); +} diff --git a/tests/c/c_ClientConfigurationTest.cc b/tests/c/c_ClientConfigurationTest.cc index f22f28a4..3fec51a5 100644 --- a/tests/c/c_ClientConfigurationTest.cc +++ b/tests/c/c_ClientConfigurationTest.cc @@ -28,4 +28,7 @@ TEST(C_ClientConfigurationTest, testCApiConfig) { ASSERT_STREQ(pulsar_client_configuration_get_tls_private_key_file_path(conf), "private.key"); ASSERT_STREQ(pulsar_client_configuration_get_tls_certificate_file_path(conf), "certificate.pem"); + + pulsar_client_configuration_set_listener_name(conf, "listenerName"); + ASSERT_STREQ(pulsar_client_configuration_get_listener_name(conf), "listenerName"); }