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/loggable_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/// config | path to the config file with data | ''
34/// format | config format, either `json` or `yaml` | 'json'
35/// missing-ok | do not terminate components load if no file found by the config option | false
36/// environment-secrets-key | name of environment variable from which to load additional data | -
37/// update-period | period between data updates in utils::StringToDuration() suitable format ('0s' for no updates) | 0s
38/// blocking-task-processor | name of task processor for background blocking operations | --
39
40// clang-format on
41
42class Secdist final : public LoggableComponentBase {
43 public:
44 /// @ingroup userver_component_names
45 /// @brief The default name of components::Secdist
46 static constexpr std::string_view kName = "secdist";
47
48 Secdist(const ComponentConfig&, const ComponentContext&);
49
50 const storages::secdist::SecdistConfig& Get() const;
51
52 rcu::ReadablePtr<storages::secdist::SecdistConfig> GetSnapshot() const;
53
54 storages::secdist::Secdist& GetStorage();
55
56 static yaml_config::Schema GetStaticConfigSchema();
57
58 private:
59 storages::secdist::Secdist secdist_;
60};
61
62template <>
63inline constexpr bool kHasValidate<Secdist> = true;
64
65} // namespace components
66
67USERVER_NAMESPACE_END