50 int64_t lfc_interval = 0;
51 int64_t connect_timeout = 0;
52 int64_t read_timeout = 0;
53 int64_t write_timeout = 0;
54 int64_t tcp_user_timeout = 0;
56 int64_t max_reconnect_tries = 0;
57 int64_t reconnect_wait_time = 0;
58 int64_t max_row_errors = 0;
61 for (
auto const& param : database_config->mapValue()) {
63 if ((param.first ==
"persist") ||
64 (param.first ==
"readonly") ||
65 (param.first ==
"retry-on-startup")) {
66 values_copy[param.first] = (param.second->boolValue() ?
69 }
else if (param.first ==
"lfc-interval") {
70 lfc_interval = param.second->intValue();
71 values_copy[param.first] =
72 boost::lexical_cast<std::string>(lfc_interval);
74 }
else if (param.first ==
"connect-timeout") {
75 connect_timeout = param.second->intValue();
76 values_copy[param.first] =
77 boost::lexical_cast<std::string>(connect_timeout);
79 }
else if (param.first ==
"read-timeout") {
80 read_timeout = param.second->intValue();
81 values_copy[param.first] =
82 boost::lexical_cast<std::string>(read_timeout);
84 }
else if (param.first ==
"write-timeout") {
85 write_timeout = param.second->intValue();
86 values_copy[param.first] =
87 boost::lexical_cast<std::string>(write_timeout);
89 }
else if (param.first ==
"tcp-user-timeout") {
90 tcp_user_timeout = param.second->intValue();
91 values_copy[param.first] =
92 boost::lexical_cast<std::string>(tcp_user_timeout);
94 }
else if (param.first ==
"max-reconnect-tries") {
95 max_reconnect_tries = param.second->intValue();
96 values_copy[param.first] =
97 boost::lexical_cast<std::string>(max_reconnect_tries);
99 }
else if (param.first ==
"reconnect-wait-time") {
100 reconnect_wait_time = param.second->intValue();
101 values_copy[param.first] =
102 boost::lexical_cast<std::string>(reconnect_wait_time);
104 }
else if (param.first ==
"port") {
105 port = param.second->intValue();
106 values_copy[param.first] =
107 boost::lexical_cast<std::string>(port);
109 }
else if (param.first ==
"max-row-errors") {
110 max_row_errors = param.second->intValue();
111 values_copy[param.first] =
112 boost::lexical_cast<std::string>(max_row_errors);
128 values_copy[param.first] = param.second->stringValue();
133 "parameter '" << param.first <<
"' ("
134 << param.second->getPosition() <<
")");
141 auto type_ptr = values_copy.find(
"type");
142 if (type_ptr == values_copy.end()) {
144 "database access parameters must "
145 "include the keyword 'type' to determine type of database "
146 "to be accessed (" << database_config->getPosition() <<
")");
153 string dbtype = type_ptr->second;
154 if ((dbtype !=
"memfile") &&
155 (dbtype !=
"mysql") &&
156 (dbtype !=
"postgresql")) {
159 <<
" (" << value->getPosition() <<
")");
163 if ((lfc_interval < 0) ||
164 (lfc_interval > std::numeric_limits<uint32_t>::max())) {
167 <<
" is out of range, expected value: 0.."
168 << std::numeric_limits<uint32_t>::max()
169 <<
" (" << value->getPosition() <<
")");
173 if ((connect_timeout < 0) ||
174 (connect_timeout > std::numeric_limits<uint32_t>::max())) {
177 <<
" is out of range, expected value: 0.."
178 << std::numeric_limits<uint32_t>::max()
179 <<
" (" << value->getPosition() <<
")");
181 if ((read_timeout < 0) ||
182 (read_timeout > std::numeric_limits<uint32_t>::max())) {
185 <<
" is out of range, expected value: 0.."
186 << std::numeric_limits<uint32_t>::max()
187 <<
" (" << value->getPosition() <<
")");
189 if (read_timeout > 0 && (dbtype !=
"mysql")) {
192 <<
" (" << value->getPosition() <<
")");
194 if ((write_timeout < 0) ||
195 (write_timeout > std::numeric_limits<uint32_t>::max())) {
198 <<
" is out of range, expected value: 0.."
199 << std::numeric_limits<uint32_t>::max()
200 <<
" (" << value->getPosition() <<
")");
202 if (write_timeout > 0 && (dbtype !=
"mysql")) {
205 <<
" (" << value->getPosition() <<
")");
207 if ((tcp_user_timeout < 0) ||
208 (tcp_user_timeout > std::numeric_limits<uint32_t>::max())) {
211 <<
" is out of range, expected value: 0.."
212 << std::numeric_limits<uint32_t>::max()
213 <<
" (" << value->getPosition() <<
")");
215 if (tcp_user_timeout > 0 && (dbtype !=
"postgresql")) {
218 <<
" (" << value->getPosition() <<
")");
223 (port > std::numeric_limits<uint16_t>::max())) {
226 <<
" is out of range, expected value: 0.."
227 << std::numeric_limits<uint16_t>::max()
228 <<
" (" << value->getPosition() <<
")");
232 if ((max_row_errors < 0) ||
233 (max_row_errors > std::numeric_limits<uint32_t>::max())) {
236 <<
" is out of range, expected value: 0.."
237 << std::numeric_limits<uint32_t>::max()
238 <<
" (" << value->getPosition() <<
")");
242 if (max_reconnect_tries < 0) {
245 "max-reconnect-tries cannot be less than zero: ("
246 << value->getPosition() <<
")");
250 if ((reconnect_wait_time < 0) ||
251 (reconnect_wait_time > std::numeric_limits<uint32_t>::max())) {
254 <<
" must be in range 0...MAX_UINT32 (4294967295) "
255 <<
"(" << value->getPosition() <<
")");
259 auto password_ptr = values_copy.find(
"password");
260 auto password_file_ptr = values_copy.find(
"password-file");
261 if ((password_ptr != values_copy.end()) &&
262 (password_file_ptr != values_copy.end())) {
264 <<
"'password-file'");
271 values_.swap(values_copy);