format-selector: Coroutinize simple methods

These all are just straightfowrard usage of co_await's around the code.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2022-04-22 13:00:25 +03:00
parent 8a6f8c622d
commit 93df88aac4

View File

@@ -7,6 +7,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <seastar/core/coroutine.hh>
#include "sstables-format-selector.hh"
#include "log.hh"
#include "replica/database.hh"
@@ -61,31 +62,27 @@ future<> sstables_format_selector::do_maybe_select_format(sstables::sstable_vers
future<> sstables_format_selector::start() {
assert(this_shard_id() == 0);
return read_sstables_format().then([this] {
_features.local().me_sstable.when_enabled(_me_feature_listener);
_features.local().md_sstable.when_enabled(_md_feature_listener);
return make_ready_future<>();
});
co_await read_sstables_format();
_features.local().me_sstable.when_enabled(_me_feature_listener);
_features.local().md_sstable.when_enabled(_md_feature_listener);
}
future<> sstables_format_selector::stop() {
return _sel.close();
co_await _sel.close();
}
future<> sstables_format_selector::read_sstables_format() {
return db::system_keyspace::get_scylla_local_param(SSTABLE_FORMAT_PARAM_NAME).then([this] (std::optional<sstring> format_opt) {
if (format_opt) {
sstables::sstable_version_types format = sstables::from_string(*format_opt);
return select_format(format);
}
return make_ready_future<>();
});
std::optional<sstring> format_opt = co_await db::system_keyspace::get_scylla_local_param(SSTABLE_FORMAT_PARAM_NAME);
if (format_opt) {
sstables::sstable_version_types format = sstables::from_string(*format_opt);
co_await select_format(format);
}
}
future<> sstables_format_selector::select_format(sstables::sstable_version_types format) {
logger.info("Selected {} sstables format", to_string(format));
_selected_format = format;
return _db.invoke_on_all([this] (replica::database& db) {
co_await _db.invoke_on_all([this] (replica::database& db) {
db.set_format(_selected_format);
});
}