11#pragma once
22
3+ // / @file userver/ydb/topic.hpp
4+ // / @brief YDB Topic client
5+
36#include < chrono>
47#include < memory>
58#include < string>
@@ -15,6 +18,14 @@ class Driver;
1518struct TopicSettings ;
1619} // namespace impl
1720
21+ // / @brief Read session used to connect to one or more topics for reading
22+ // /
23+ // / @see https://ydb.tech/docs/en/reference/ydb-sdk/topic#reading
24+ // /
25+ // / ## Example usage:
26+ // /
27+ // / @snippet userver/samples/ydb_service/components/topic_reader.hpp Sample
28+ // / Topic reader
1829class TopicReadSession final {
1930 public:
2031 // / @cond
@@ -23,17 +34,32 @@ class TopicReadSession final {
2334 std::shared_ptr<NYdb::NTopic::IReadSession> read_session);
2435 // / @endcond
2536
37+ // / @brief Get read session events
38+ // /
39+ // / Waits until event occurs
40+ // / @param max_events_count maximum events count in batch
41+ // / if not specified, read session chooses event batch size automatically
2642 std::vector<NYdb::NTopic::TReadSessionEvent::TEvent> GetEvents (
2743 std::optional<std::size_t > max_events_count = {});
2844
45+ // / @brief Close read session
46+ // /
47+ // / Waits for all commit acknowledgments to arrive.
48+ // / Force close after timeout
2949 bool Close (std::chrono::milliseconds timeout);
3050
51+ // / Get native read session
3152 std::shared_ptr<NYdb::NTopic::IReadSession> GetNativeTopicReadSession ();
3253
3354 private:
3455 std::shared_ptr<NYdb::NTopic::IReadSession> read_session_;
3556};
3657
58+ // / @ingroup userver_clients
59+ // /
60+ // / @brief YDB Topic Client
61+ // /
62+ // / @see https://ydb.tech/docs/en/concepts/topic
3763class TopicClient final {
3864 public:
3965 // / @cond
@@ -44,14 +70,18 @@ class TopicClient final {
4470
4571 ~TopicClient ();
4672
73+ // / Alter topic
4774 void AlterTopic (const std::string& path,
4875 const NYdb::NTopic::TAlterTopicSettings& settings);
4976
77+ // / Describe topic
5078 NYdb::NTopic::TDescribeTopicResult DescribeTopic (const std::string& path);
5179
80+ // / Create read session
5281 TopicReadSession CreateReadSession (
5382 const NYdb::NTopic::TReadSessionSettings& settings);
5483
84+ // / Get native topic client
5585 NYdb::NTopic::TTopicClient& GetNativeTopicClient ();
5686
5787 private:
0 commit comments