2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
44#include "net/config/ConfigSection.hpp"
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
48#include "log/Logger.h"
57namespace net::config {
63 "Automatically retry listen|connect",
66 CLI::IsMember({
"true",
"false"})
);
69 "--retry-on-fatal{true}",
75 "Retry also on fatal errors",
78 CLI::IsMember({
"true",
"false"})
);
81 retryTimeoutOpt = addOption(
83 "Timeout of the retry timer",
86 CLI::NonNegativeNumber);
89 retryTriesOpt = addOption(
91 "Number of retry attempts before giving up (0 = unlimited)",
94 CLI::TypeValidator<
unsigned int>());
97 retryBaseOpt = addOption(
99 "Base of exponential backoff",
102 CLI::PositiveNumber);
105 retryJitterOpt = addOption(
107 "Maximum jitter in percent to apply randomly to calculated retry timeout (0 to disable)",
110 CLI::Range(0., 100.));
113 retryLimitOpt = addOption(
115 "Upper limit in seconds of retry timeout (0 for infinite)",
118 CLI::NonNegativeNumber);
129 const std::string& description,
130 const std::string& typeName,
131 const std::string& defaultValue,
132 const CLI::Validator& validator) {
135 [
this, strippedName = name.substr(0, name.find(
'{')), optLevel, optName]() {
138 if (
section->get_option(strippedName)->as<
bool>()) {
143 }
catch ([[maybe_unused]]
CLI::ConversionError& err) {
151 }
catch (
CLI::OptionNotFound& err) {
152 LOG(ERROR) << err.what();
191 ->default_val(retry ?
"true" :
"false")
219 ->default_val(retry ?
"true" :
"false")
279 ->default_val(percent)
ConfigPhysicalSocket & setRetryTimeout(double sec)
double getRetryTimeout() const
unsigned int getRetryTries() const
ConfigPhysicalSocket & setRetryJitter(double percent)
CLI::Option * retryJitterOpt
double getRetryJitter() const
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, int optValue)
unsigned int getRetryLimit() const
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, const std::string &optValue)
CLI::Option * retryBaseOpt
ConfigPhysicalSocket(ConfigInstance *instance)
bool getRetryOnFatal() const
ConfigPhysicalSocket & removeSocketOption(int optLevel, int optName)
CLI::Option * retryTriesOpt
ConfigPhysicalSocket & setRetryOnFatal(bool retry=true)
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, const std::vector< char > &optValue)
ConfigPhysicalSocket & setRetryLimit(unsigned int limit)
std::map< int, std::map< int, const net::phy::PhysicalSocketOption > > socketOptionsMapMap
double getRetryBase() const
ConfigPhysicalSocket & setRetry(bool retry=true)
const std::map< int, std::map< int, const net::phy::PhysicalSocketOption > > & getSocketOptions()
ConfigPhysicalSocket & setRetryBase(double base)
CLI::Option * addSocketOption(const std::string &name, int optLevel, int optName, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)
CLI::Option * retryOnFatalOpt
CLI::Option * retryTimeoutOpt
CLI::Option * retryLimitOpt
ConfigPhysicalSocket & setRetryTries(unsigned int tries=0)
ConfigSection(ConfigInstance *instance, const std::string &name, const std::string &description)
CLI::Option * addFlag(const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator)
CLI::Option * addFlagFunction(const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)
PhysicalSocketOption(int optLevel, int optName, int optValue)
PhysicalSocketOption(int optLevel, int optName, const std::vector< char > &optValue)
PhysicalSocketOption(int optLevel, int optName, const std::string &optValue)