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
26namespace pulsar {
27class PulsarWrapper;
28struct ClientConfigurationImpl;
29class PULSAR_PUBLIC ClientConfiguration {
30 public:
35 enum ProxyProtocol
36 {
37 SNI = 0
38 };
39
46 ClientConfiguration& setMemoryLimit(uint64_t memoryLimitBytes);
47
51 uint64_t getMemoryLimit() const;
52
61 ClientConfiguration& setConnectionsPerBroker(int connectionsPerBroker);
62
67
73 ClientConfiguration& setAuth(const AuthenticationPtr& authentication);
74
79
87
92
100
104 int getIOThreads() const;
105
117
122
131 ClientConfiguration& setConcurrentLookupRequest(int concurrentLookupRequest);
132
137
145
150
157 ClientConfiguration& setInitialBackoffIntervalMs(int initialBackoffIntervalMs);
158
163
171
176
189
198
202 bool isUseTls() const;
203
209 ClientConfiguration& setTlsPrivateKeyFilePath(const std::string& tlsKeyFilePath);
210
214 const std::string& getTlsPrivateKeyFilePath() const;
215
221 ClientConfiguration& setTlsCertificateFilePath(const std::string& tlsCertificateFilePath);
222
226 const std::string& getTlsCertificateFilePath() const;
227
233 ClientConfiguration& setTlsTrustCertsFilePath(const std::string& tlsTrustCertsFilePath);
234
238 const std::string& getTlsTrustCertsFilePath() const;
239
248
253
268
272 bool isValidateHostName() const;
273
279 ClientConfiguration& setListenerName(const std::string& listenerName);
280
284 const std::string& getListenerName() const;
285
294
298 const unsigned int& getStatsIntervalInSeconds() const;
299
309 ClientConfiguration& setPartititionsUpdateInterval(unsigned int intervalInSeconds);
310
314 unsigned int getPartitionsUpdateInterval() const;
315
326
336 ClientConfiguration& setProxyServiceUrl(const std::string& proxyServiceUrl);
337
338 const std::string& getProxyServiceUrl() const;
339
350 ClientConfiguration& setProxyProtocol(ProxyProtocol proxyProtocol);
351
352 ProxyProtocol getProxyProtocol() const;
353
358
365 ClientConfiguration& setKeepAliveIntervalInSeconds(unsigned int keepAliveIntervalInSeconds);
366
370 unsigned int getKeepAliveIntervalInSeconds() const;
371
372 friend class ClientImpl;
373 friend class PulsarWrapper;
374
375 private:
376 const AuthenticationPtr& getAuthPtr() const;
377 std::shared_ptr<ClientConfigurationImpl> impl_;
378
379 // By default, when the client connects to the broker, a version string like "Pulsar-CPP-v<x.y.z>" will be
380 // carried and saved by the broker. The client version string could be queried from the topic stats.
381 //
382 // This method provides a way to add more description to a specific `Client` instance. If it's configured,
383 // the description will be appended to the original client version string, with '-' as the separator.
384 //
385 // For example, if the client version is 3.2.0, and the description is "forked", the final client version
386 // string will be "Pulsar-CPP-v3.2.0-forked".
387 //
388 // NOTE: This method should only be called by the PulsarWrapper and the length should not exceed 64.
389 //
390 // For example, you can add a PulsarWrapper class like:
391 //
392 // ```c++
393 // namespace pulsar {
394 // class PulsarWrapper {
395 // static ClientConfiguration clientConfig() {
396 // ClientConfiguration conf;
397 // conf.setDescription("forked");
398 // return conf;
399 // }
400 // };
401 // }
402 // ```
403 //
404 // Then, call the method before passing the `conf` to the constructor of `Client`:
405 //
406 // ```c++
407 // auto conf = PulsarWrapper::clientConfig();
408 // // Set other attributes of `conf` here...
409 // Client client{"pulsar://localhost:6650", conf);
410 // ```
411 ClientConfiguration& setDescription(const std::string& description);
412
413 const std::string& getDescription() const noexcept;
414};
415} // namespace pulsar
416
417#endif /* PULSAR_CLIENTCONFIGURATION_H_ */
Definition Authentication.h:88
Definition ClientConfiguration.h:29
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