userver: userver/urabbitmq/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/urabbitmq/component.hpp
4/// @brief @copybrief components::RabbitMQ
5
6#include <memory>
7
8#include <userver/components/component_base.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace clients::dns {
13class Component;
14}
15
16namespace urabbitmq {
17class Client;
18}
19
20namespace components {
21
22/// @ingroup userver_components
23///
24/// @brief RabbitMQ (AMQP 0.9.1) client component
25///
26/// Provides access to a RabbitMQ cluster.
27///
28/// ## Static configuration example:
29///
30/// @snippet samples/rabbitmq_service/static_config.yaml RabbitMQ service sample - static config
31///
32/// If the component is configured with an secdist_alias, it will lookup
33/// connection data in secdist.json via secdist_alias value, otherwise via
34/// components name.
35///
36/// ## Secdist format
37///
38/// A RabbitMQ alias in secdist is described as a JSON object
39/// 'rabbitmq_settings', containing descriptions of RabbitMQ clusters.
40///
41/// @snippet samples/rabbitmq_service/tests/conftest.py RabbitMQ service sample - secdist
42///
43/// ## Static options of components::RabbitMQ :
44/// @include{doc} scripts/docs/en/components_schema/rabbitmq/src/urabbitmq/component.md
45///
46/// Options inherited from @ref components::ComponentBase :
47/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
48class RabbitMQ final : public ComponentBase {
49public:
50 /// Component constructor
51 RabbitMQ(const ComponentConfig& config, const ComponentContext& context);
52 /// Component destructor
53 ~RabbitMQ() override;
54
55 /// Cluster accessor
56 std::shared_ptr<urabbitmq::Client> GetClient() const;
57
58 static yaml_config::Schema GetStaticConfigSchema();
59
60private:
61 clients::dns::Component& dns_;
62 std::shared_ptr<urabbitmq::Client> client_;
63};
64
65template <>
66inline constexpr bool kHasValidate<RabbitMQ> = true;
67
68} // namespace components
69
70USERVER_NAMESPACE_END