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