userver: userver/storages/secdist/provider_component.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
provider_component.hpp
1#pragma once
2
3/// @file userver/storages/secdist/component.hpp
4/// @brief @copybrief components::DefaultSecdistProvider
5
6#include <string>
7
8#include <userver/components/loggable_component_base.hpp>
9#include <userver/storages/secdist/provider.hpp>
10#include <userver/storages/secdist/secdist.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace storages::secdist {
15
16class DefaultLoader final : public storages::secdist::SecdistProvider {
17 public:
18 struct Settings {
19 std::string config_path;
20 SecdistFormat format{SecdistFormat::kJson};
21 bool missing_ok{false};
22 std::optional<std::string> environment_secrets_key;
23 engine::TaskProcessor* blocking_task_processor{nullptr};
24 };
25
26 explicit DefaultLoader(Settings settings);
27
28 formats::json::Value Get() const override;
29
30 private:
31 Settings settings_;
32};
33
34} // namespace storages::secdist
35
36namespace components {
37// clang-format off
38
39/// @ingroup userver_components
40///
41/// @brief Component that stores security related data (keys, passwords, ...).
42///
43/// The component must be configured in service config.
44///
45/// ## Static options:
46/// Name | Description | Default value
47/// ---- | ----------- | -------------
48/// config | path to the config file with data | ''
49/// format | config format, either `json` or `yaml` | 'json'
50/// missing-ok | do not terminate components load if no file found by the config option | false
51/// environment-secrets-key | name of environment variable from which to load additional data | -
52/// blocking-task-processor | name of task processor for background blocking operations | --
53
54// clang-format on
55
56class DefaultSecdistProvider final : public LoggableComponentBase,
58 public:
59 /// @ingroup userver_component_names
60 /// @brief The default name of components::DefaultSecdistProvider
61 static constexpr std::string_view kName = "default-secdist-provider";
62
63 DefaultSecdistProvider(const ComponentConfig&, const ComponentContext&);
64
65 formats::json::Value Get() const override;
66
67 static yaml_config::Schema GetStaticConfigSchema();
68
69 private:
70 storages::secdist::DefaultLoader loader_;
71};
72
73template <>
74inline constexpr bool kHasValidate<DefaultSecdistProvider> = true;
75
76} // namespace components
77
78USERVER_NAMESPACE_END