26#include <unordered_map>
29#include <toml++/toml.h>
38namespace msgpack_rpc::config::toml::impl {
48 for (
const auto& [key, value] : table) {
49 const auto key_str = key.str();
50 if (key_str ==
"read_buffer_size") {
52 "read_buffer_size", read_buffer_size, std::size_t);
64 for (
const auto& [key, value] : table) {
65 const auto key_str = key.str();
66 if (key_str ==
"num_transport_threads") {
68 "num_transport_threads", num_transport_threads, std::size_t);
69 }
else if (key_str ==
"num_callback_threads") {
71 "num_callback_threads", num_callback_threads, std::size_t);
83 for (
const auto& [key, value] : table) {
84 const auto key_str = key.str();
85 if (key_str ==
"initial_waiting_time_sec") {
87 "initial_waiting_time_sec", initial_waiting_time);
88 }
else if (key_str ==
"max_waiting_time_sec") {
90 "max_waiting_time_sec", max_waiting_time);
91 }
else if (key_str ==
"max_jitter_waiting_time_sec") {
93 "max_jitter_waiting_time_sec", max_jitter_waiting_time);
105 for (
const auto& [key, value] : table) {
106 const auto key_str = key.str();
107 if (key_str ==
"uris") {
108 const auto* uris_node = value.as_array();
109 if (uris_node ==
nullptr) {
112 for (
const auto& elem : *uris_node) {
113 const auto* uri_node = elem.as_string();
114 if (uri_node ==
nullptr) {
118 config.add_uri(uri_node->get());
119 }
catch (
const std::exception& e) {
123 }
else if (key_str ==
"call_timeout_sec") {
125 "call_timeout_sec", call_timeout);
126 }
else if (key_str ==
"message_parser") {
127 const auto* child_table = value.as_table();
128 if (child_table ==
nullptr) {
132 }
else if (key_str ==
"executor") {
133 const auto* child_table = value.as_table();
134 if (child_table ==
nullptr) {
138 }
else if (key_str ==
"reconnection") {
139 const auto* child_table = value.as_table();
140 if (child_table ==
nullptr) {
155 std::unordered_map<std::string, ClientConfig>& configs) {
156 for (
const auto& [key, value] : table) {
157 const auto* table_ptr = value.as_table();
158 if (table_ptr ==
nullptr) {
160 "\"client\" must be a table of tables.");
164 configs.try_emplace(std::string(key.str()), std::move(
config));
175 for (
const auto& [key, value] : table) {
176 const auto key_str = key.str();
177 if (key_str ==
"uris") {
178 const auto* uris_node = value.as_array();
179 if (uris_node ==
nullptr) {
182 for (
const auto& elem : *uris_node) {
183 const auto* uri_node = elem.as_string();
184 if (uri_node ==
nullptr) {
188 config.add_uri(uri_node->get());
189 }
catch (
const std::exception& e) {
193 }
else if (key_str ==
"message_parser") {
194 const auto* child_table = value.as_table();
195 if (child_table ==
nullptr) {
199 }
else if (key_str ==
"executor") {
200 const auto* child_table = value.as_table();
201 if (child_table ==
nullptr) {
216 std::unordered_map<std::string, ServerConfig>& configs) {
217 for (
const auto& [key, value] : table) {
218 const auto* table_ptr = value.as_table();
219 if (table_ptr ==
nullptr) {
221 "\"server\" must be a table of tables.");
225 configs.try_emplace(std::string(key.str()), std::move(
config));
Class of configuration of clients.
Class of configuration of executors.
Class of configuration of parsers of messages.
Class of configurations of reconnection.
Class of configurations of servers.
Definition of ClientConfig class.
Definition of ExecutorConfig class.
Definition of MessageParserConfig class.
Namespace of configurations.
void parse_toml(const ::toml::table &table, MessageParserConfig &config)
Parse a configuration of parsers of messages from TOML.
Definition of common functions and macros to parse TOML files.
#define MSGPACK_RPC_PARSE_TOML_VALUE(KEY_STR, CONFIG_FUNCTION, TYPE)
Internal macro to parse a value from TOML.
void throw_error(const ::toml::source_region &source, std::string_view config_key)
Throw an exception for an error of TOML.
#define MSGPACK_RPC_PARSE_TOML_VALUE_DURATION(KEY_STR, CONFIG_FUNCTION)
Internal macro to parse a value from TOML.
Definition of ReconnectionConfig class.
Definition of ServerConfig class.