2020#define LIB_CLIENTCONFIGURATIONIMPL_H_
2121
2222#include < pulsar/ClientConfiguration.h>
23- #include < pulsar/ServiceInfo.h>
2423
2524#include < chrono>
26- #include < mutex>
27- #include < shared_mutex>
28-
29- #include " ServiceNameResolver.h"
30- #include " ServiceURI.h"
3125
3226namespace pulsar {
3327
34- // Use struct rather than class here just for ABI compatibility
3528struct ClientConfigurationImpl {
36- private:
37- mutable std::shared_mutex mutex;
3829 AuthenticationPtr authenticationPtr{AuthFactory::Disabled ()};
39- std::string tlsTrustCertsFilePath;
40- bool useTls{false };
41-
42- public:
43- void updateServiceInfo (const ServiceInfo& serviceInfo) {
44- std::unique_lock lock (mutex);
45- if (serviceInfo.authentication && serviceInfo.authentication ->getAuthMethodName () != " none" ) {
46- authenticationPtr = serviceInfo.authentication ;
47- } else {
48- authenticationPtr = AuthFactory::Disabled ();
49- }
50- if (serviceInfo.tlsTrustCertsFilePath .has_value ()) {
51- tlsTrustCertsFilePath = *serviceInfo.tlsTrustCertsFilePath ;
52- } else {
53- tlsTrustCertsFilePath = " " ;
54- }
55- useTls = ServiceNameResolver::useTls (ServiceURI (serviceInfo.serviceUrl ));
56- }
57-
58- auto & getAuthentication () const {
59- std::shared_lock lock (mutex);
60- return authenticationPtr;
61- }
62-
63- auto setAuthentication (const AuthenticationPtr& authentication) {
64- std::unique_lock lock (mutex);
65- authenticationPtr = authentication;
66- }
67-
68- auto & getTlsTrustCertsFilePath () const {
69- std::shared_lock lock (mutex);
70- return tlsTrustCertsFilePath;
71- }
72-
73- auto setTlsTrustCertsFilePath (const std::string& path) {
74- std::unique_lock lock (mutex);
75- tlsTrustCertsFilePath = path;
76- }
77-
78- auto isUseTls () const {
79- std::shared_lock lock (mutex);
80- return useTls;
81- }
82-
83- auto setUseTls (bool useTls_) {
84- std::unique_lock lock (mutex);
85- useTls = useTls_;
86- }
87-
8830 uint64_t memoryLimit{0ull };
8931 int ioThreads{1 };
9032 int connectionsPerBroker{1 };
@@ -94,8 +36,10 @@ struct ClientConfigurationImpl {
9436 int maxLookupRedirects{20 };
9537 int initialBackoffIntervalMs{100 };
9638 int maxBackoffIntervalMs{60000 };
39+ bool useTls{false };
9740 std::string tlsPrivateKeyFilePath;
9841 std::string tlsCertificateFilePath;
42+ std::string tlsTrustCertsFilePath;
9943 bool tlsAllowInsecureConnection{false };
10044 unsigned int statsIntervalInSeconds{600 }; // 10 minutes
10145 std::unique_ptr<LoggerFactory> loggerFactory;
0 commit comments