pulsar-client-cpp
Loading...
Searching...
No Matches
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#include <cstdint>
27
28namespace pulsar {
29class PulsarWrapper;
30struct ClientConfigurationImpl;
31class PULSAR_PUBLIC ClientConfiguration {
32 public:
37 enum ProxyProtocol : uint8_t
38 {
39 SNI = 0
40 };
41
48 ClientConfiguration& setMemoryLimit(uint64_t memoryLimitBytes);
49
53 uint64_t getMemoryLimit() const;
54
63 ClientConfiguration& setConnectionsPerBroker(int connectionsPerBroker);
64
69
75 ClientConfiguration& setAuth(const AuthenticationPtr& authentication);
76
81
89
94
102
106 int getIOThreads() const;
107
119
124
133 ClientConfiguration& setConcurrentLookupRequest(int concurrentLookupRequest);
134
139
147
152
159 ClientConfiguration& setInitialBackoffIntervalMs(int initialBackoffIntervalMs);
160
165
173
178
191
200
204 bool isUseTls() const;
205
211 ClientConfiguration& setTlsPrivateKeyFilePath(const std::string& tlsKeyFilePath);
212
216 const std::string& getTlsPrivateKeyFilePath() const;
217
223 ClientConfiguration& setTlsCertificateFilePath(const std::string& tlsCertificateFilePath);
224
228 const std::string& getTlsCertificateFilePath() const;
229
235 ClientConfiguration& setTlsTrustCertsFilePath(const std::string& tlsTrustCertsFilePath);
236
240 const std::string& getTlsTrustCertsFilePath() const;
241
250
255
270
274 bool isValidateHostName() const;
275
281 ClientConfiguration& setListenerName(const std::string& listenerName);
282
286 const std::string& getListenerName() const;
287
296
300 const unsigned int& getStatsIntervalInSeconds() const;
301
311 ClientConfiguration& setPartititionsUpdateInterval(unsigned int intervalInSeconds);
312
316 unsigned int getPartitionsUpdateInterval() const;
317
328
338 ClientConfiguration& setProxyServiceUrl(const std::string& proxyServiceUrl);
339
340 const std::string& getProxyServiceUrl() const;
341
352 ClientConfiguration& setProxyProtocol(ProxyProtocol proxyProtocol);
353
354 ProxyProtocol getProxyProtocol() const;
355
360
367 ClientConfiguration& setKeepAliveIntervalInSeconds(unsigned int keepAliveIntervalInSeconds);
368
372 unsigned int getKeepAliveIntervalInSeconds() const;
373
374 friend class ClientImpl;
375 friend class PulsarWrapper;
376
377 private:
378 const AuthenticationPtr& getAuthPtr() const;
379 std::shared_ptr<ClientConfigurationImpl> impl_;
380
381 // By default, when the client connects to the broker, a version string like "Pulsar-CPP-v<x.y.z>" will be
382 // carried and saved by the broker. The client version string could be queried from the topic stats.
383 //
384 // This method provides a way to add more description to a specific `Client` instance. If it's configured,
385 // the description will be appended to the original client version string, with '-' as the separator.
386 //
387 // For example, if the client version is 3.2.0, and the description is "forked", the final client version
388 // string will be "Pulsar-CPP-v3.2.0-forked".
389 //
390 // NOTE: This method should only be called by the PulsarWrapper and the length should not exceed 64.
391 //
392 // For example, you can add a PulsarWrapper class like:
393 //
394 // ```c++
395 // namespace pulsar {
396 // class PulsarWrapper {
397 // static ClientConfiguration clientConfig() {
398 // ClientConfiguration conf;
399 // conf.setDescription("forked");
400 // return conf;
401 // }
402 // };
403 // }
404 // ```
405 //
406 // Then, call the method before passing the `conf` to the constructor of `Client`:
407 //
408 // ```c++
409 // auto conf = PulsarWrapper::clientConfig();
410 // // Set other attributes of `conf` here...
411 // Client client{"pulsar://localhost:6650", conf);
412 // ```
413 ClientConfiguration& setDescription(const std::string& description);
414
415 const std::string& getDescription() const noexcept;
416};
417} // namespace pulsar
418
419#endif /* PULSAR_CLIENTCONFIGURATION_H_ */
Definition Authentication.h:88
Definition ClientConfiguration.h:31
int getConnectionsPerBroker() const
ClientConfiguration & setStatsIntervalInSeconds(const unsigned int &)
int getInitialBackoffIntervalMs() const
ClientConfiguration & setValidateHostName(bool validateHostName)
bool isTlsAllowInsecureConnection() const
ClientConfiguration & setLogger(LoggerFactory *loggerFactory)
const std::string & getTlsTrustCertsFilePath() const
ClientConfiguration & setAuth(const AuthenticationPtr &authentication)
const std::string & getListenerName() const
Authentication & getAuth() const
ClientConfiguration & setConnectionsPerBroker(int connectionsPerBroker)
const unsigned int & getStatsIntervalInSeconds() const
unsigned int getKeepAliveIntervalInSeconds() const
ClientConfiguration & setMaxBackoffIntervalMs(int maxBackoffIntervalMs)
const std::string & getTlsCertificateFilePath() const
ClientConfiguration & setPartititionsUpdateInterval(unsigned int intervalInSeconds)
ClientConfiguration & setMessageListenerThreads(int threads)
ClientConfiguration & setTlsTrustCertsFilePath(const std::string &tlsTrustCertsFilePath)
ClientConfiguration & setConnectionTimeout(int timeoutMs)
int getMaxBackoffIntervalMs() const
ClientConfiguration & setIOThreads(int threads)
int getOperationTimeoutSeconds() const
ClientConfiguration & setTlsCertificateFilePath(const std::string &tlsCertificateFilePath)
ClientConfiguration & setProxyServiceUrl(const std::string &proxyServiceUrl)
int getMessageListenerThreads() const
const std::string & getTlsPrivateKeyFilePath() const
ClientConfiguration & setTlsPrivateKeyFilePath(const std::string &tlsKeyFilePath)
ClientConfiguration & setConcurrentLookupRequest(int concurrentLookupRequest)
unsigned int getPartitionsUpdateInterval() const
ClientConfiguration & setTlsAllowInsecureConnection(bool allowInsecure)
uint64_t getMemoryLimit() const
ClientConfiguration & setKeepAliveIntervalInSeconds(unsigned int keepAliveIntervalInSeconds)
int getConcurrentLookupRequest() const
ClientConfiguration & setMaxLookupRedirects(int maxLookupRedirects)
ClientConfiguration & setOperationTimeoutSeconds(int timeout)
ClientConfiguration & setListenerName(const std::string &listenerName)
ClientConfiguration & setProxyProtocol(ProxyProtocol proxyProtocol)
ClientConfiguration & setMemoryLimit(uint64_t memoryLimitBytes)
ClientConfiguration & setUseTls(bool useTls)
ClientConfiguration & setInitialBackoffIntervalMs(int initialBackoffIntervalMs)
Definition Logger.h:58
Definition Authentication.h:31