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 <string>
8#include <vector>
9
10#include <userver/yaml_config/yaml_config.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace error_injection {
15
16/// What error injection hook may decide to do
17enum class Verdict {
18 kError, ///< return error
19 kTimeout, ///< wait for deadline and return error
20 kMaxDelay, ///< wait for deadline w/o returning an error
21 kRandomDelay, ///< wait for [0; deadline] w/o returning an error
22
23 // Skip must be the last
24
25 kSkip, ///< no error
26};
27
28/// Artificial error injection settings
29struct Settings final {
30 /// error injection enabled
31 bool enabled{false};
32
33 /// error probability from range [0, 1]
34 double probability{0};
35
36 /// possible verdicts, will be chosen randomly, Verdict::Error if unspecified
38};
39
40Settings Parse(const yaml_config::YamlConfig& value, formats::parse::To<Settings>);
41
42} // namespace error_injection
43
44USERVER_NAMESPACE_END