diff --git a/configure.py b/configure.py index 0510c8602f..e1f28ed9c6 100755 --- a/configure.py +++ b/configure.py @@ -490,6 +490,7 @@ scylla_core = (['database.cc', 'frozen_schema.cc', 'schema_registry.cc', 'bytes.cc', + 'timeout_config.cc', 'mutation.cc', 'mutation_fragment.cc', 'partition_version.cc', diff --git a/redis/service.cc b/redis/service.cc index 0b857507e9..3f33850d1b 100644 --- a/redis/service.cc +++ b/redis/service.cc @@ -19,6 +19,7 @@ * along with Scylla. If not, see . */ +#include "timeout_config.hh" #include "redis/service.hh" #include "redis/keyspace_utils.hh" #include "redis/server.hh" @@ -45,18 +46,6 @@ future<> redis_service::listen(distributed& auth_service, db::con auto server = make_shared>(); _server = server; - auto make_timeout_config = [] (db::config& cfg) { - timeout_config tc; - tc.read_timeout = cfg.read_request_timeout_in_ms() * 1ms; - tc.write_timeout = cfg.write_request_timeout_in_ms() * 1ms; - tc.range_read_timeout = cfg.range_request_timeout_in_ms() * 1ms; - tc.counter_write_timeout = cfg.counter_write_request_timeout_in_ms() * 1ms; - tc.truncate_timeout = cfg.truncate_request_timeout_in_ms() * 1ms; - tc.cas_timeout = cfg.cas_contention_timeout_in_ms() * 1ms; - tc.other_timeout = cfg.request_timeout_in_ms() * 1ms; - return tc; - }; - auto addr = cfg.rpc_address(); auto preferred = cfg.rpc_interface_prefer_ipv6() ? std::make_optional(net::inet_address::family::INET6) : std::nullopt; auto family = cfg.enable_ipv6_dns_lookup() || preferred ? std::nullopt : std::make_optional(net::inet_address::family::INET); diff --git a/service/storage_service.cc b/service/storage_service.cc index 10a9a675ed..bc9e4ff6e5 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -86,8 +86,6 @@ using token = dht::token; using UUID = utils::UUID; using inet_address = gms::inet_address; -using namespace std::chrono_literals; - extern logging::logger cdc_log; namespace service { @@ -99,18 +97,6 @@ static const sstring SSTABLE_FORMAT_PARAM_NAME = "sstable_format"; distributed _the_storage_service; -timeout_config make_timeout_config(const db::config& cfg) { - timeout_config tc; - tc.read_timeout = cfg.read_request_timeout_in_ms() * 1ms; - tc.write_timeout = cfg.write_request_timeout_in_ms() * 1ms; - tc.range_read_timeout = cfg.range_request_timeout_in_ms() * 1ms; - tc.counter_write_timeout = cfg.counter_write_request_timeout_in_ms() * 1ms; - tc.truncate_timeout = cfg.truncate_request_timeout_in_ms() * 1ms; - tc.cas_timeout = cfg.cas_contention_timeout_in_ms() * 1ms; - tc.other_timeout = cfg.request_timeout_in_ms() * 1ms; - return tc; -} - int get_generation_number() { using namespace std::chrono; auto now = high_resolution_clock::now().time_since_epoch(); diff --git a/timeout_config.cc b/timeout_config.cc new file mode 100644 index 0000000000..8b15e4f382 --- /dev/null +++ b/timeout_config.cc @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 ScyllaDB + * + */ + +/* + * This file is part of Scylla. + * + * Scylla is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Scylla is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Scylla. If not, see . + */ + +#include "timeout_config.hh" +#include "db/config.hh" + +using namespace std::chrono_literals; + +timeout_config make_timeout_config(const db::config& cfg) { + timeout_config tc; + tc.read_timeout = cfg.read_request_timeout_in_ms() * 1ms; + tc.write_timeout = cfg.write_request_timeout_in_ms() * 1ms; + tc.range_read_timeout = cfg.range_request_timeout_in_ms() * 1ms; + tc.counter_write_timeout = cfg.counter_write_request_timeout_in_ms() * 1ms; + tc.truncate_timeout = cfg.truncate_request_timeout_in_ms() * 1ms; + tc.cas_timeout = cfg.cas_contention_timeout_in_ms() * 1ms; + tc.other_timeout = cfg.request_timeout_in_ms() * 1ms; + return tc; +} diff --git a/timeout_config.hh b/timeout_config.hh index 8144a1da95..6c6afdb629 100644 --- a/timeout_config.hh +++ b/timeout_config.hh @@ -37,3 +37,6 @@ struct timeout_config { using timeout_config_selector = db::timeout_clock::duration (timeout_config::*); extern const timeout_config infinite_timeout_config; + +namespace db { class config; } +timeout_config make_timeout_config(const db::config& cfg);