userver
C++ Async Framework
Loading...
Searching...
No Matches
rebalance_types.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/kafka/rebalance_types.hpp
4
/// @brief Kafka consumer rebalance callback types
5
6
#
include
<
cstdint
>
7
#
include
<
functional
>
8
#
include
<
optional
>
9
10
#
include
<
userver
/
utils
/
span
.
hpp
>
11
#
include
<
userver
/
utils
/
zstring_view
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
kafka {
16
17
enum
class
RebalanceEventType { kAssigned, kRevoked };
18
19
/// @brief Represents the topic's partition for certain topic.
20
struct
TopicPartitionView
final
{
21
/// @brief Topic's name.
22
utils
::
zstring_view
topic
;
23
24
/// @brief Partition ID for a topic
25
std::
uint32_t
partition_id
;
26
27
/// @brief Offset for current partition if it has committed offset
28
std::optional<std::
uint64_t
>
offset
;
29
30
TopicPartitionView(
utils
::
zstring_view
topic, std::uint32_t partition_id, std::optional<std::uint64_t> offset)
31
:
topic
{topic},
32
partition_id
{partition_id},
33
offset
{offset}
34
{}
35
};
36
37
using
TopicPartitionBatchView =
utils
::
span
<
const
TopicPartitionView>;
38
39
/// @brief Callback invoked when a rebalance event occurs.
40
/// @warning The rebalance callback should be set before calling ConsumerScope::Start or after ConsumerScope::Stop.
41
/// The callback must not throw exceptions; any thrown exceptions will be caught and logged by the consumer
42
/// implementation.
43
/// @note The callback is invoked after the assign or revoke event has been successfully processed.
44
using
ConsumerRebalanceCallback = std::function<
void
(TopicPartitionBatchView, RebalanceEventType)>;
45
46
}
// namespace kafka
47
48
USERVER_NAMESPACE_END
userver
kafka
rebalance_types.hpp
Generated on Thu May 21 2026 16:21:02 for userver by
Doxygen
1.13.2