pulsar-client-cpp
Loading...
Searching...
No Matches
Client.h
1
19#ifndef PULSAR_CLIENT_HPP_
20#define PULSAR_CLIENT_HPP_
21
22#include <pulsar/ClientConfiguration.h>
23#include <pulsar/ConsoleLoggerFactory.h>
24#include <pulsar/Consumer.h>
25#include <pulsar/FileLoggerFactory.h>
26#include <pulsar/Message.h>
27#include <pulsar/MessageBuilder.h>
28#include <pulsar/Producer.h>
29#include <pulsar/Reader.h>
30#include <pulsar/Result.h>
31#include <pulsar/Schema.h>
32#include <pulsar/TableView.h>
33#include <pulsar/defines.h>
34
35#include <string>
36
37namespace pulsar {
38typedef std::function<void(Result, Producer)> CreateProducerCallback;
39typedef std::function<void(Result, Consumer)> SubscribeCallback;
40typedef std::function<void(Result, Reader)> ReaderCallback;
41typedef std::function<void(Result, TableView)> TableViewCallback;
42typedef std::function<void(Result, const std::vector<std::string>&)> GetPartitionsCallback;
43typedef std::function<void(Result)> CloseCallback;
44
45class ClientImpl;
46class PulsarFriend;
47class PulsarWrapper;
48
49class PULSAR_PUBLIC Client {
50 public:
58 Client(const std::string& serviceUrl);
59
69 Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration);
70
81 Result createProducer(const std::string& topic, Producer& producer);
82
94 Result createProducer(const std::string& topic, const ProducerConfiguration& conf, Producer& producer);
95
104 void createProducerAsync(const std::string& topic, CreateProducerCallback callback);
105
113 void createProducerAsync(const std::string& topic, ProducerConfiguration conf,
114 CreateProducerCallback callback);
115
124 Result subscribe(const std::string& topic, const std::string& subscriptionName, Consumer& consumer);
125
134 Result subscribe(const std::string& topic, const std::string& subscriptionName,
135 const ConsumerConfiguration& conf, Consumer& consumer);
136
146 void subscribeAsync(const std::string& topic, const std::string& subscriptionName,
147 SubscribeCallback callback);
148
159 void subscribeAsync(const std::string& topic, const std::string& subscriptionName,
160 const ConsumerConfiguration& conf, SubscribeCallback callback);
161
169 Result subscribe(const std::vector<std::string>& topics, const std::string& subscriptionName,
170 Consumer& consumer);
171
180 Result subscribe(const std::vector<std::string>& topics, const std::string& subscriptionName,
181 const ConsumerConfiguration& conf, Consumer& consumer);
182
193 void subscribeAsync(const std::vector<std::string>& topics, const std::string& subscriptionName,
194 SubscribeCallback callback);
195
206 void subscribeAsync(const std::vector<std::string>& topics, const std::string& subscriptionName,
207 const ConsumerConfiguration& conf, SubscribeCallback callback);
208
212 Result subscribeWithRegex(const std::string& regexPattern, const std::string& subscriptionName,
213 Consumer& consumer);
214
219 Result subscribeWithRegex(const std::string& regexPattern, const std::string& subscriptionName,
220 const ConsumerConfiguration& conf, Consumer& consumer);
221
229 void subscribeWithRegexAsync(const std::string& regexPattern, const std::string& subscriptionName,
230 SubscribeCallback callback);
231
242 void subscribeWithRegexAsync(const std::string& regexPattern, const std::string& subscriptionName,
243 const ConsumerConfiguration& conf, SubscribeCallback callback);
244
274 Result createReader(const std::string& topic, const MessageId& startMessageId,
275 const ReaderConfiguration& conf, Reader& reader);
276
303 void createReaderAsync(const std::string& topic, const MessageId& startMessageId,
304 const ReaderConfiguration& conf, ReaderCallback callback);
305
318 Result createTableView(const std::string& topic, const TableViewConfiguration& conf,
319 TableView& tableView);
320
333 void createTableViewAsync(const std::string& topic, const TableViewConfiguration& conf,
334 TableViewCallback callBack);
335
349 Result getPartitionsForTopic(const std::string& topic, std::vector<std::string>& partitions);
350
366 void getPartitionsForTopicAsync(const std::string& topic, GetPartitionsCallback callback);
367
373
383 void closeAsync(CloseCallback callback);
384
391 void shutdown();
392
399
406
414 void getSchemaInfoAsync(const std::string& topic, int64_t version,
415 std::function<void(Result, const SchemaInfo&)> callback);
416
417 private:
418 Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
419 bool poolConnections);
420 Client(const std::shared_ptr<ClientImpl>);
421
422 friend class PulsarFriend;
423 friend class PulsarWrapper;
424 std::shared_ptr<ClientImpl> impl_;
425};
426} // namespace pulsar
427
428#endif /* PULSAR_CLIENT_HPP_ */
Definition ClientConfiguration.h:29
Definition Client.h:49
Result subscribeWithRegex(const std::string &regexPattern, const std::string &subscriptionName, Consumer &consumer)
Result subscribeWithRegex(const std::string &regexPattern, const std::string &subscriptionName, const ConsumerConfiguration &conf, Consumer &consumer)
uint64_t getNumberOfConsumers()
Get the number of alive consumers on the current client.
Result subscribe(const std::string &topic, const std::string &subscriptionName, const ConsumerConfiguration &conf, Consumer &consumer)
Client(const std::string &serviceUrl, const ClientConfiguration &clientConfiguration)
Result getPartitionsForTopic(const std::string &topic, std::vector< std::string > &partitions)
void getPartitionsForTopicAsync(const std::string &topic, GetPartitionsCallback callback)
void subscribeAsync(const std::vector< std::string > &topics, const std::string &subscriptionName, SubscribeCallback callback)
void createProducerAsync(const std::string &topic, ProducerConfiguration conf, CreateProducerCallback callback)
void subscribeWithRegexAsync(const std::string &regexPattern, const std::string &subscriptionName, SubscribeCallback callback)
uint64_t getNumberOfProducers()
Get the number of alive producers on the current client.
void subscribeAsync(const std::string &topic, const std::string &subscriptionName, SubscribeCallback callback)
void createProducerAsync(const std::string &topic, CreateProducerCallback callback)
void subscribeAsync(const std::string &topic, const std::string &subscriptionName, const ConsumerConfiguration &conf, SubscribeCallback callback)
Result subscribe(const std::vector< std::string > &topics, const std::string &subscriptionName, const ConsumerConfiguration &conf, Consumer &consumer)
Result createProducer(const std::string &topic, Producer &producer)
Result subscribe(const std::string &topic, const std::string &subscriptionName, Consumer &consumer)
void getSchemaInfoAsync(const std::string &topic, int64_t version, std::function< void(Result, const SchemaInfo &)> callback)
Result createProducer(const std::string &topic, const ProducerConfiguration &conf, Producer &producer)
Result createTableView(const std::string &topic, const TableViewConfiguration &conf, TableView &tableView)
void createReaderAsync(const std::string &topic, const MessageId &startMessageId, const ReaderConfiguration &conf, ReaderCallback callback)
void subscribeWithRegexAsync(const std::string &regexPattern, const std::string &subscriptionName, const ConsumerConfiguration &conf, SubscribeCallback callback)
Result close()
Client(const std::string &serviceUrl)
void closeAsync(CloseCallback callback)
Result createReader(const std::string &topic, const MessageId &startMessageId, const ReaderConfiguration &conf, Reader &reader)
void createTableViewAsync(const std::string &topic, const TableViewConfiguration &conf, TableViewCallback callBack)
Result subscribe(const std::vector< std::string > &topics, const std::string &subscriptionName, Consumer &consumer)
void subscribeAsync(const std::vector< std::string > &topics, const std::string &subscriptionName, const ConsumerConfiguration &conf, SubscribeCallback callback)
Definition ConsumerConfiguration.h:65
Definition Consumer.h:37
Definition MessageId.h:34
Definition ProducerConfiguration.h:45
Definition Producer.h:36
Definition ReaderConfiguration.h:49
Definition Reader.h:37
Definition Schema.h:146
Definition TableView.h:38
Definition Authentication.h:31
Result
Definition Result.h:32
Definition TableViewConfiguration.h:27