mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
messaging: convert do_get_rpc_client_idx into a switch
A switch is more readable for multiple choice with no clearly preferred choice.
This commit is contained in:
@@ -395,27 +395,29 @@ rpc::no_wait_type messaging_service::no_wait() {
|
||||
|
||||
|
||||
static constexpr unsigned do_get_rpc_client_idx(messaging_verb verb) {
|
||||
unsigned idx = 0;
|
||||
switch (verb) {
|
||||
// GET_SCHEMA_VERSION is sent from read/mutate verbs so should be
|
||||
// sent on a different connection to avoid potential deadlocks
|
||||
// as well as reduce latency as there are potentially many requests
|
||||
// blocked on schema version request.
|
||||
if (verb == messaging_verb::GOSSIP_DIGEST_SYN ||
|
||||
verb == messaging_verb::GOSSIP_DIGEST_ACK2 ||
|
||||
verb == messaging_verb::GOSSIP_SHUTDOWN ||
|
||||
verb == messaging_verb::GOSSIP_ECHO ||
|
||||
verb == messaging_verb::GET_SCHEMA_VERSION) {
|
||||
idx = 1;
|
||||
} else if (verb == messaging_verb::PREPARE_MESSAGE ||
|
||||
verb == messaging_verb::PREPARE_DONE_MESSAGE ||
|
||||
verb == messaging_verb::STREAM_MUTATION ||
|
||||
verb == messaging_verb::STREAM_MUTATION_DONE ||
|
||||
verb == messaging_verb::COMPLETE_MESSAGE) {
|
||||
idx = 2;
|
||||
} else if (verb == messaging_verb::MUTATION_DONE || verb == messaging_verb::MUTATION_FAILED) {
|
||||
idx = 3;
|
||||
case messaging_verb::GOSSIP_DIGEST_SYN:
|
||||
case messaging_verb::GOSSIP_DIGEST_ACK2:
|
||||
case messaging_verb::GOSSIP_SHUTDOWN:
|
||||
case messaging_verb::GOSSIP_ECHO:
|
||||
case messaging_verb::GET_SCHEMA_VERSION:
|
||||
return 1;
|
||||
case messaging_verb::PREPARE_MESSAGE:
|
||||
case messaging_verb::PREPARE_DONE_MESSAGE:
|
||||
case messaging_verb::STREAM_MUTATION:
|
||||
case messaging_verb::STREAM_MUTATION_DONE:
|
||||
case messaging_verb::COMPLETE_MESSAGE:
|
||||
return 2;
|
||||
case messaging_verb::MUTATION_DONE:
|
||||
case messaging_verb::MUTATION_FAILED:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
static constexpr std::array<uint8_t, static_cast<size_t>(messaging_verb::LAST)> make_rpc_client_idx_table() {
|
||||
|
||||
Reference in New Issue
Block a user