userver: userver/ydb/topic.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
topic.hpp
1#pragma once
2
3#include <chrono>
4#include <memory>
5#include <string>
6
7#include <ydb-cpp-sdk/client/topic/topic.h>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace ydb {
12
13namespace impl {
14class Driver;
15struct TopicSettings;
16} // namespace impl
17
18class TopicReadSession final {
19 public:
20 /// @cond
21 // For internal use only.
22 explicit TopicReadSession(
23 std::shared_ptr<NYdb::NTopic::IReadSession> read_session);
24 /// @endcond
25
26 std::vector<NYdb::NTopic::TReadSessionEvent::TEvent> GetEvents(
27 std::optional<std::size_t> max_events_count = {});
28
29 bool Close(std::chrono::milliseconds timeout);
30
31 std::shared_ptr<NYdb::NTopic::IReadSession> GetNativeTopicReadSession();
32
33 private:
34 std::shared_ptr<NYdb::NTopic::IReadSession> read_session_;
35};
36
37class TopicClient final {
38 public:
39 /// @cond
40 // For internal use only.
41 TopicClient(std::shared_ptr<impl::Driver> driver,
42 impl::TopicSettings settings);
43 /// @endcond
44
45 ~TopicClient();
46
47 void AlterTopic(const std::string& path,
48 const NYdb::NTopic::TAlterTopicSettings& settings);
49
50 NYdb::NTopic::TDescribeTopicResult DescribeTopic(const std::string& path);
51
52 TopicReadSession CreateReadSession(
53 const NYdb::NTopic::TReadSessionSettings& settings);
54
55 NYdb::NTopic::TTopicClient& GetNativeTopicClient();
56
57 private:
58 std::shared_ptr<impl::Driver> driver_;
59 NYdb::NTopic::TTopicClient topic_client_;
60};
61
62} // namespace ydb
63
64USERVER_NAMESPACE_END