userver
C++ Async Framework
Loading...
Searching...
No Matches
topic_writer_types.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/ydb/topic_writer_types.hpp
4
/// @brief Types for YDB topic writer
5
6
#
include
<
memory
>
7
#
include
<
string
>
8
#
include
<
string_view
>
9
#
include
<
unordered_map
>
10
11
#
include
<
ydb
-
cpp
-
sdk
/
client
/
topic
/
write_events
.
h
>
12
13
#
include
<
userver
/
utils
/
impl
/
internal_tag
.
hpp
>
14
15
USERVER_NAMESPACE_BEGIN
16
17
namespace
ydb {
18
19
namespace
impl {
20
struct
TopicWriterHandlingResult;
21
}
22
23
/// Metadata associated with a YDB topic message (key-value pairs)
24
using
TopicWriterMetadata = std::unordered_map<std::string, std::string>;
25
26
/// YDB write acknowledgement event state.
27
/// @see https://ydb.tech/docs/en/reference/ydb-sdk/topic#write
28
using
TopicWriteEventState = NYdb::NTopic::TWriteSessionEvent::TWriteAck::EEventState;
29
30
/// @brief Provides status code for storing messages to the internal queue
31
enum
class
TopicWriteStatus
:
std
::
size_t
{
32
/// Message has been put into the internal queue
33
kOk
,
34
/// Internal queue is full
35
kResourceExhausted
,
36
/// Other error
37
kFail
,
38
/// Not used for the moment, we accept all messages for handling
39
kNotReady
,
40
/// @warning Do not use this value
41
kMaxCount
42
};
43
44
/// @brief Provides the result of the message handling
45
///
46
/// @note Although initially this interface was intended to be awaitable,
47
/// underlying YDB driver doesn't support waiting for result without
48
/// enabled deduplication.
49
class
TopicWriteResult
{
50
public
:
51
/// @brief Constructs a write result
52
/// @param status the status of the write operation
53
explicit
TopicWriteResult
(
TopicWriteStatus
status);
54
55
/// @cond
56
// For internal use only.
57
/// @brief Constructs a write result
58
/// @param status the status of the write operation
59
/// @param context internal handling result context (may be nullptr)
60
TopicWriteResult(
61
utils
::impl::InternalTag,
62
TopicWriteStatus
status,
63
std::shared_ptr<impl::TopicWriterHandlingResult> context
64
);
65
/// @endcond
66
67
/// Status of whether the message has been accepted for handling by the
68
/// library. Note that this status does not reflect the result of the
69
/// message processing by YDB itself.
70
TopicWriteStatus
GetStatus
()
const
{
return
status_; }
71
72
private
:
73
TopicWriteStatus
status_;
74
std::shared_ptr<impl::TopicWriterHandlingResult> context_;
75
};
76
77
/// @brief Converts TopicWriteStatus to a human-readable string view
78
/// @param status the status to convert
79
/// @return string_view representation of the status
80
std::string_view
ToStringView
(
TopicWriteStatus
status);
81
82
}
// namespace ydb
83
84
USERVER_NAMESPACE_END
userver
ydb
topic_writer_types.hpp
Generated on Tue Jun 30 2026 13:18:51 for userver by
Doxygen
1.13.2