19#ifndef PULSAR_CLIENT_HPP_
20#define PULSAR_CLIENT_HPP_
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/ServiceInfo.h>
33#include <pulsar/ServiceInfoProvider.h>
34#include <pulsar/TableView.h>
35#include <pulsar/defines.h>
44typedef std::function<void(
Result,
Producer)> CreateProducerCallback;
46typedef std::function<void(
Result,
Reader)> ReaderCallback;
48typedef std::function<void(
Result,
const std::vector<std::string>&)> GetPartitionsCallback;
49typedef std::function<void(
Result)> CloseCallback;
51using CreateProducerV2Callback = std::function<void(std::variant<Error, Producer>)>;
52using CreateConsumerV2Callback = std::function<void(std::variant<Error, Consumer>)>;
53using SubscribeV2Callback = CreateConsumerV2Callback;
54using ReaderV2Callback = std::function<void(std::variant<Error, Reader>)>;
55using TableViewV2Callback = std::function<void(std::variant<Error, TableView>)>;
61 explicit TopicRegex(std::string pattern) : pattern(std::move(pattern)) {}
66using SubscribeTopics = std::variant<std::string, std::vector<std::string>,
TopicRegex>;
81 Client(
const std::string& serviceUrl);
105 static Client create(std::unique_ptr<ServiceInfoProvider> serviceInfoProvider,
144 const std::string& topic,
const CreateProducerCallback& callback);
154 const std::string& topic,
const ProducerConfiguration& conf,
const CreateProducerCallback& callback);
157 CreateProducerV2Callback callback);
159 std::variant<Error, Producer> createProducerV2(
const std::string& topic,
192 void subscribeAsync(
const std::string& topic,
const std::string& subscriptionName,
193 const SubscribeCallback& callback);
205 void subscribeAsync(
const std::string& topic,
const std::string& subscriptionName,
208 void subscribeAsyncV2(
const SubscribeTopics& topics,
const std::string& subscriptionName,
211 std::variant<Error, Consumer> subscribeV2(
const SubscribeTopics& topics,
212 const std::string& subscriptionName,
222 Result subscribe(
const std::vector<std::string>& topics,
const std::string& subscriptionName,
233 Result subscribe(
const std::vector<std::string>& topics,
const std::string& subscriptionName,
246 void subscribeAsync(
const std::vector<std::string>& topics,
const std::string& subscriptionName,
247 const SubscribeCallback& callback);
259 void subscribeAsync(
const std::vector<std::string>& topics,
const std::string& subscriptionName,
283 const SubscribeCallback& callback);
359 void createReaderAsyncV2(
const std::string& topic,
const MessageId& startMessageId,
362 std::variant<Error, Reader> createReaderV2(
const std::string& topic,
const MessageId& startMessageId,
393 const TableViewCallback& callBack);
396 TableViewV2Callback callback);
398 std::variant<Error, TableView> createTableViewV2(
const std::string& topic,
490 Client(
const std::shared_ptr<ClientImpl>&);
492 friend class PulsarFriend;
493 friend class PulsarWrapper;
494 std::shared_ptr<ClientImpl> impl_;
Definition ClientConfiguration.h:31
static Client create(std::unique_ptr< ServiceInfoProvider > serviceInfoProvider, const ClientConfiguration &clientConfiguration)
void closeAsync(const CloseCallback &callback)
Result subscribeWithRegex(const std::string ®exPattern, const std::string &subscriptionName, Consumer &consumer)
void subscribeAsync(const std::string &topic, const std::string &subscriptionName, const ConsumerConfiguration &conf, const SubscribeCallback &callback)
Result subscribeWithRegex(const std::string ®exPattern, 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 subscribeAsync(const std::string &topic, const std::string &subscriptionName, const SubscribeCallback &callback)
void subscribeAsync(const std::vector< std::string > &topics, const std::string &subscriptionName, const SubscribeCallback &callback)
void subscribeWithRegexAsync(const std::string ®exPattern, const std::string &subscriptionName, const SubscribeCallback &callback)
void createReaderAsync(const std::string &topic, const MessageId &startMessageId, const ReaderConfiguration &conf, const ReaderCallback &callback)
ServiceInfo getServiceInfo() const
void createProducerAsync(const std::string &topic, const ProducerConfiguration &conf, const CreateProducerCallback &callback)
uint64_t getNumberOfProducers()
Get the number of alive producers on the current client.
void createProducerAsync(const std::string &topic, const CreateProducerCallback &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)
void subscribeAsync(const std::vector< std::string > &topics, const std::string &subscriptionName, const ConsumerConfiguration &conf, const SubscribeCallback &callback)
Result createProducer(const std::string &topic, const ProducerConfiguration &conf, Producer &producer)
Result createTableView(const std::string &topic, const TableViewConfiguration &conf, TableView &tableView)
Client(const std::string &serviceUrl)
void subscribeWithRegexAsync(const std::string ®exPattern, const std::string &subscriptionName, const ConsumerConfiguration &conf, const SubscribeCallback &callback)
void createTableViewAsync(const std::string &topic, const TableViewConfiguration &conf, const TableViewCallback &callBack)
Result createReader(const std::string &topic, const MessageId &startMessageId, const ReaderConfiguration &conf, Reader &reader)
Result subscribe(const std::vector< std::string > &topics, const std::string &subscriptionName, Consumer &consumer)
void getPartitionsForTopicAsync(const std::string &topic, const GetPartitionsCallback &callback)
Definition ConsumerConfiguration.h:65
Definition MessageId.h:34
Definition ProducerConfiguration.h:46
Definition ReaderConfiguration.h:49
Definition ServiceInfo.h:33
Definition TableView.h:38
Definition Authentication.h:31
Result
Definition Result.h:35
Definition TableViewConfiguration.h:27