pulsar-client-cpp
ClientConfiguration.h
1 
19 #ifndef PULSAR_CLIENTCONFIGURATION_H_
20 #define PULSAR_CLIENTCONFIGURATION_H_
21 
22 #include <pulsar/Authentication.h>
23 #include <pulsar/Logger.h>
24 #include <pulsar/defines.h>
25 
26 namespace pulsar {
27 class PulsarWrapper;
28 struct ClientConfigurationImpl;
29 class PULSAR_PUBLIC ClientConfiguration {
30  public:
34  ClientConfiguration& operator=(const ClientConfiguration&);
35 
42  ClientConfiguration& setMemoryLimit(uint64_t memoryLimitBytes);
43 
47  uint64_t getMemoryLimit() const;
48 
54  ClientConfiguration& setAuth(const AuthenticationPtr& authentication);
55 
59  Authentication& getAuth() const;
60 
67  ClientConfiguration& setOperationTimeoutSeconds(int timeout);
68 
72  int getOperationTimeoutSeconds() const;
73 
80  ClientConfiguration& setIOThreads(int threads);
81 
85  int getIOThreads() const;
86 
97  ClientConfiguration& setMessageListenerThreads(int threads);
98 
102  int getMessageListenerThreads() const;
103 
112  ClientConfiguration& setConcurrentLookupRequest(int concurrentLookupRequest);
113 
117  int getConcurrentLookupRequest() const;
118 
125  ClientConfiguration& setMaxLookupRedirects(int maxLookupRedirects);
126 
130  int getMaxLookupRedirects() const;
131 
138  ClientConfiguration& setInitialBackoffIntervalMs(int initialBackoffIntervalMs);
139 
143  int getInitialBackoffIntervalMs() const;
144 
151  ClientConfiguration& setMaxBackoffIntervalMs(int maxBackoffIntervalMs);
152 
156  int getMaxBackoffIntervalMs() const;
157 
164  ClientConfiguration& setLogConfFilePath(const std::string& logConfFilePath);
165 
169  const std::string& getLogConfFilePath() const;
170 
182  ClientConfiguration& setLogger(LoggerFactory* loggerFactory);
183 
191  ClientConfiguration& setUseTls(bool useTls);
192 
196  bool isUseTls() const;
197 
203  ClientConfiguration& setTlsPrivateKeyFilePath(const std::string& tlsKeyFilePath);
204 
208  const std::string& getTlsPrivateKeyFilePath() const;
209 
215  ClientConfiguration& setTlsCertificateFilePath(const std::string& tlsCertificateFilePath);
216 
220  const std::string& getTlsCertificateFilePath() const;
221 
227  ClientConfiguration& setTlsTrustCertsFilePath(const std::string& tlsTrustCertsFilePath);
228 
232  const std::string& getTlsTrustCertsFilePath() const;
233 
241  ClientConfiguration& setTlsAllowInsecureConnection(bool allowInsecure);
242 
246  bool isTlsAllowInsecureConnection() const;
247 
261  ClientConfiguration& setValidateHostName(bool validateHostName);
262 
266  bool isValidateHostName() const;
267 
273  ClientConfiguration& setListenerName(const std::string& listenerName);
274 
278  const std::string& getListenerName() const;
279 
287  ClientConfiguration& setStatsIntervalInSeconds(const unsigned int&);
288 
292  const unsigned int& getStatsIntervalInSeconds() const;
293 
303  ClientConfiguration& setPartititionsUpdateInterval(unsigned int intervalInSeconds);
304 
308  unsigned int getPartitionsUpdateInterval() const;
309 
319  ClientConfiguration& setConnectionTimeout(int timeoutMs);
320 
324  int getConnectionTimeout() const;
325 
326  friend class ClientImpl;
327  friend class PulsarWrapper;
328 
329  private:
330  const AuthenticationPtr& getAuthPtr() const;
331  std::shared_ptr<ClientConfigurationImpl> impl_;
332 
333  // By default, when the client connects to the broker, a version string like "Pulsar-CPP-v<x.y.z>" will be
334  // carried and saved by the broker. The client version string could be queried from the topic stats.
335  //
336  // This method provides a way to add more description to a specific `Client` instance. If it's configured,
337  // the description will be appended to the original client version string, with '-' as the separator.
338  //
339  // For example, if the client version is 3.2.0, and the description is "forked", the final client version
340  // string will be "Pulsar-CPP-v3.2.0-forked".
341  //
342  // NOTE: This method should only be called by the PulsarWrapper and the length should not exceed 64.
343  //
344  // For example, you can add a PulsarWrapper class like:
345  //
346  // ```c++
347  // namespace pulsar {
348  // class PulsarWrapper {
349  // static ClientConfiguration clientConfig() {
350  // ClientConfiguration conf;
351  // conf.setDescription("forked");
352  // return conf;
353  // }
354  // };
355  // }
356  // ```
357  //
358  // Then, call the method before passing the `conf` to the constructor of `Client`:
359  //
360  // ```c++
361  // auto conf = PulsarWrapper::clientConfig();
362  // // Set other attributes of `conf` here...
363  // Client client{"pulsar://localhost:6650", conf);
364  // ```
365  ClientConfiguration& setDescription(const std::string& description);
366 
367  const std::string& getDescription() const noexcept;
368 };
369 } // namespace pulsar
370 
371 #endif /* PULSAR_CLIENTCONFIGURATION_H_ */
pulsar::LoggerFactory
Definition: Logger.h:58
pulsar::ClientConfiguration
Definition: ClientConfiguration.h:29
pulsar
Definition: Authentication.h:31
pulsar::Authentication
Definition: Authentication.h:88