Files
scylla/timeout_config.cc
Kefu Chai ebf5e138e8 redis,thrift,transport: make timeout_config live-updateable
* timeout_config
  - add `updated_timeout_config` which represents an always-updated
    options backed by `utils::updateable_value<>`. this class is
    used by servers which need to access the latest timeout related
    options. the existing `timeout_config` is more like a snapshot
    of the `updated_timeout_config`. it is used in the use case where
    we don't need to most updated options or we update the options
    manually on demand.
* redis, thrift, transport: s/timeout_config/updated_timeout_config/
  when appropriate. use the improved version of timeout_config where
  we need to have the access to the most-updated version of the timeout
  options.

Fixes #10172
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-29 20:17:45 +08:00

43 lines
1.4 KiB
C++

/*
* Copyright (C) 2020-present ScyllaDB
*
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include "timeout_config.hh"
#include "db/config.hh"
#include "db/timeout_clock.hh"
#include <chrono>
#include <seastar/core/future.hh>
using namespace std::chrono_literals;
updateable_timeout_config::updateable_timeout_config(const db::config& cfg)
: read_timeout_in_ms(cfg.read_request_timeout_in_ms)
, write_timeout_in_ms(cfg.write_request_timeout_in_ms)
, range_read_timeout_in_ms(cfg.range_request_timeout_in_ms)
, counter_write_timeout_in_ms(cfg.counter_write_request_timeout_in_ms)
, truncate_timeout_in_ms(cfg.counter_write_request_timeout_in_ms)
, cas_timeout_in_ms(cfg.cas_contention_timeout_in_ms)
, other_timeout_in_ms(cfg.request_timeout_in_ms)
{}
timeout_config updateable_timeout_config::current_values() const {
return {
std::chrono::milliseconds(read_timeout_in_ms),
std::chrono::milliseconds(write_timeout_in_ms),
std::chrono::milliseconds(range_read_timeout_in_ms),
std::chrono::milliseconds(counter_write_timeout_in_ms),
std::chrono::milliseconds(truncate_timeout_in_ms),
std::chrono::milliseconds(cas_timeout_in_ms),
std::chrono::milliseconds(cas_timeout_in_ms),
};
}
timeout_config make_timeout_config(const db::config& cfg) {
return updateable_timeout_config(cfg).current_values();
}