userver
C++ Async Framework
Loading...
Searching...
No Matches
producer_component.hpp
1
#
pragma
once
2
3
#
include
<
string_view
>
4
5
#
include
<
userver
/
kafka
/
producer
.
hpp
>
6
7
#
include
<
userver
/
components
/
component_base
.
hpp
>
8
#
include
<
userver
/
utils
/
statistics
/
entry
.
hpp
>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
kafka {
13
14
/// @ingroup userver_components
15
///
16
/// @brief Apache Kafka Producer client component.
17
///
18
/// ## Static configuration example:
19
///
20
/// @snippet samples/kafka_service/static_config.yaml Kafka service sample - producer static config
21
///
22
/// ## Secdist format
23
///
24
/// A Kafka alias in secdist is described as a JSON object
25
/// `kafka_settings`, containing credentials of Kafka brokers.
26
///
27
/// @snippet samples/kafka_service/testsuite/conftest.py Kafka service sample - secdist
28
///
29
/// ## Static options of kafka::ProducerComponent:
30
/// @include{doc} scripts/docs/en/components_schema/kafka/src/kafka/producer_component.md
31
///
32
/// Options inherited from @ref components::ComponentBase :
33
/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
34
class
ProducerComponent
final
:
public
components
::
ComponentBase
{
35
public
:
36
/// @ingroup userver_component_names
37
/// @brief The default name of kafka::ProducerComponent component
38
static
constexpr
std::string_view
kName
{
"kafka-producer"
};
39
40
ProducerComponent(
const
components
::ComponentConfig& config,
const
components
::ComponentContext& context);
41
~ProducerComponent()
override
;
42
43
/// @brief Returns a producer instance reference.
44
/// @see kafka::Producer
45
const
Producer&
GetProducer
();
46
47
static
yaml_config
::Schema GetStaticConfigSchema();
48
49
private
:
50
Producer producer_;
51
52
/// @note Subscriptions must be the last fields! Add new fields above this
53
/// comment.
54
utils::statistics::Entry statistics_holder_;
55
};
56
57
}
// namespace kafka
58
59
USERVER_NAMESPACE_END
userver
kafka
producer_component.hpp
Generated on Fri Dec 5 2025 12:22:29 for userver by
Doxygen
1.13.2