userver: userver/storages/secdist/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/secdist/component.hpp
4/// @brief @copybrief components::Secdist
5
6#include <string>
7
8#include <userver/components/component_base.hpp>
9#include <userver/storages/secdist/secdist.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace components {
14// clang-format off
15
16/// @ingroup userver_components
17///
18/// @brief Component that stores security related data (keys, passwords, ...).
19///
20/// The component must be configured in service config.
21///
22/// Secdist requires a provider storages::secdist::SecdistProvider
23/// You can implement your own or use components::DefaultSecdistProvider
24///
25/// ## Static configuration example:
26///
27/// @snippet samples/redis_service/static_config.yaml Sample secdist static config
28///
29/// ## Static options:
30/// Name | Description | Default value
31/// ---- | ----------- | -------------
32/// provider | optional secdist provider component name | 'default-secdist-provider'
33/// update-period | period between data updates in utils::StringToDuration() suitable format ('0s' for no updates) | 0s
34
35// clang-format on
36
37class Secdist final : public ComponentBase {
38public:
39 /// @ingroup userver_component_names
40 /// @brief The default name of components::Secdist
41 static constexpr std::string_view kName = "secdist";
42
43 Secdist(const ComponentConfig&, const ComponentContext&);
44
45 const storages::secdist::SecdistConfig& Get() const;
46
47 rcu::ReadablePtr<storages::secdist::SecdistConfig> GetSnapshot() const;
48
49 storages::secdist::Secdist& GetStorage();
50
51 static yaml_config::Schema GetStaticConfigSchema();
52
53private:
54 storages::secdist::Secdist secdist_;
55};
56
57template <>
58inline constexpr bool kHasValidate<Secdist> = true;
59
60template <>
61inline constexpr auto kConfigFileMode<Secdist> = ConfigFileMode::kNotRequired;
62
63} // namespace components
64
65USERVER_NAMESPACE_END