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
359 friend class ClientImpl;
360 friend class PulsarWrapper;
361
362 private:
363 const AuthenticationPtr& getAuthPtr() const;
364 std::shared_ptr<ClientConfigurationImpl> impl_;
365
366 // By default, when the client connects to the broker, a version string like "Pulsar-CPP-v<x.y.z>" will be
367 // carried and saved by the broker. The client version string could be queried from the topic stats.
368 //
369 // This method provides a way to add more description to a specific `Client` instance. If it's configured,
370 // the description will be appended to the original client version string, with '-' as the separator.
371 //
372 // For example, if the client version is 3.2.0, and the description is "forked", the final client version
373 // string will be "Pulsar-CPP-v3.2.0-forked".
374 //
375 // NOTE: This method should only be called by the PulsarWrapper and the length should not exceed 64.
376 //
377 // For example, you can add a PulsarWrapper class like:
378 //
379 // ```c++
380 // namespace pulsar {
381 // class PulsarWrapper {
382 // static ClientConfiguration clientConfig() {
383 // ClientConfiguration conf;
384 // conf.setDescription("forked");
385 // return conf;
386 // }
387 // };
388 // }
389 // ```
390 //
391 // Then, call the method before passing the `conf` to the constructor of `Client`:
392 //
393 // ```c++
394 // auto conf = PulsarWrapper::clientConfig();
395 // // Set other attributes of `conf` here...
396 // Client client{"pulsar://localhost:6650", conf);
397 // ```
398 ClientConfiguration& setDescription(const std::string& description);
399
400 const std::string& getDescription() const noexcept;
401};
402} // namespace pulsar
403
404#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
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
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