userver: userver/error_injection/settings.hpp Source File
Loading...
Searching...
No Matches
settings.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/error_injection/settings.hpp
4/// @brief Artificial error injection settings and verdict types
5
6#include <memory>
7#include <vector>
8
9#include <userver/yaml_config/yaml_config.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace error_injection {
14
15/// What error injection hook may decide to do
16enum class Verdict {
17 kError, ///< return error
18 kTimeout, ///< wait for deadline and return error
19 kMaxDelay, ///< wait for deadline w/o returning an error
20 kRandomDelay, ///< wait for [0; deadline] w/o returning an error
21
22 // Skip must be the last
23
24 kSkip, ///< no error
25};
26
27/// Artificial error injection settings
28struct Settings final {
29 /// error injection enabled
30 bool enabled{false};
31
32 /// error probability from range [0, 1]
33 double probability{0};
34
35 /// possible verdicts, will be chosen randomly, Verdict::Error if unspecified
37};
38
39Settings Parse(const yaml_config::YamlConfig& value, formats::parse::To<Settings>);
40
41} // namespace error_injection
42
43USERVER_NAMESPACE_END