|
| 1 | +#pragma once |
| 2 | + |
| 3 | +/// @file userver/storages/secdist/component_base.hpp |
| 4 | +/// @brief @copybrief components::SecdistComponentBase |
| 5 | + |
| 6 | +#include <string> |
| 7 | + |
| 8 | +#include <userver/components/loggable_component_base.hpp> |
| 9 | +#include <userver/storages/secdist/secdist.hpp> |
| 10 | + |
| 11 | +USERVER_NAMESPACE_BEGIN |
| 12 | + |
| 13 | +namespace 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 | + |
| 42 | +class SecdistComponentBase : public LoggableComponentBase { |
| 43 | + public: |
| 44 | + SecdistComponentBase(const ComponentConfig&, const ComponentContext&, |
| 45 | + storages::secdist::SecdistConfig::Settings&&); |
| 46 | + |
| 47 | + const storages::secdist::SecdistConfig& Get() const; |
| 48 | + |
| 49 | + rcu::ReadablePtr<storages::secdist::SecdistConfig> GetSnapshot() const; |
| 50 | + |
| 51 | + storages::secdist::Secdist& GetStorage(); |
| 52 | + |
| 53 | + static yaml_config::Schema GetStaticConfigSchema(); |
| 54 | + |
| 55 | + private: |
| 56 | + storages::secdist::Secdist secdist_; |
| 57 | +}; |
| 58 | + |
| 59 | +} // namespace components |
| 60 | + |
| 61 | +USERVER_NAMESPACE_END |
0 commit comments