diff --git a/cql3/statements/batch_statement.hh b/cql3/statements/batch_statement.hh index 06a4157b67..63f299aac8 100644 --- a/cql3/statements/batch_statement.hh +++ b/cql3/statements/batch_statement.hh @@ -16,6 +16,7 @@ #include "log.hh" #include "service_permit.hh" #include "exceptions/exceptions.hh" +#include "exceptions/coordinator_result.hh" namespace cql_transport::messages { class result_message; diff --git a/cql3/statements/index_prop_defs.cc b/cql3/statements/index_prop_defs.cc index c0fea83cf5..eacf9cf66a 100644 --- a/cql3/statements/index_prop_defs.cc +++ b/cql3/statements/index_prop_defs.cc @@ -12,6 +12,7 @@ */ #include +#include #include "index_prop_defs.hh" #include "index/secondary_index.hh" #include "exceptions/exceptions.hh" diff --git a/cql3/statements/modification_statement.hh b/cql3/statements/modification_statement.hh index f195bd2220..8a239a31d7 100644 --- a/cql3/statements/modification_statement.hh +++ b/cql3/statements/modification_statement.hh @@ -22,6 +22,7 @@ #include "cql3/restrictions/statement_restrictions.hh" #include "cql3/statements/statement_type.hh" #include "exceptions/exceptions.hh" +#include "exceptions/coordinator_result.hh" #include diff --git a/cql3/statements/property_definitions.cc b/cql3/statements/property_definitions.cc index a2053c228f..11284768d9 100644 --- a/cql3/statements/property_definitions.cc +++ b/cql3/statements/property_definitions.cc @@ -11,6 +11,7 @@ * SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0) */ +#include #include "cql3/statements/property_definitions.hh" #include "exceptions/exceptions.hh" diff --git a/cql3/statements/select_statement.hh b/cql3/statements/select_statement.hh index 6876da27af..7990029a71 100644 --- a/cql3/statements/select_statement.hh +++ b/cql3/statements/select_statement.hh @@ -20,6 +20,7 @@ #include "transport/messages/result_message.hh" #include "index/secondary_index_manager.hh" #include "exceptions/exceptions.hh" +#include "exceptions/coordinator_result.hh" namespace service { class client_state; diff --git a/exceptions/coordinator_result.hh b/exceptions/coordinator_result.hh new file mode 100644 index 0000000000..0195e08194 --- /dev/null +++ b/exceptions/coordinator_result.hh @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022-present ScyllaDB + */ + +/* + * SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0) + */ + +#pragma once + +#include "exceptions.hh" +#include +#include "utils/exception_container.hh" +#include "utils/result.hh" + +namespace exceptions { + +// Allows to pass a coordinator exception as a value. With coordinator_result, +// it is possible to handle exceptions and inspect their type/value without +// resorting to costly rethrows. On the other hand, using them is more +// cumbersome than just using exceptions and exception futures. +// +// Not all exceptions are passed in this way, therefore the container +// does not allow all types of coordinator exceptions. On the other hand, +// an exception being listed here does not mean it is _always_ passed +// in an exception_container - it can be thrown in a regular fashion +// as well. +// +// It is advised to use this mechanism mainly for exceptions which can +// happen frequently, e.g. signalling timeouts, overloads or rate limits. +using coordinator_exception_container = utils::exception_container< + mutation_write_timeout_exception, + read_timeout_exception, + read_failure_exception +>; + +template +using coordinator_result = bo::result; + +} diff --git a/exceptions/exceptions.hh b/exceptions/exceptions.hh index 90df64e2b7..5479c335f6 100644 --- a/exceptions/exceptions.hh +++ b/exceptions/exceptions.hh @@ -18,9 +18,6 @@ #include #include #include "bytes.hh" -#include -#include "utils/exception_container.hh" -#include "utils/result.hh" namespace exceptions { @@ -295,29 +292,4 @@ public: function_execution_exception(sstring func_name_, sstring detail, sstring ks_name_, std::vector args_) noexcept; }; -// Allows to pass a coordinator exception as a value. With coordinator_result, -// it is possible to handle exceptions and inspect their type/value without -// resorting to costly rethrows. On the other hand, using them is more -// cumbersome than just using exceptions and exception futures. -// -// Not all exceptions are passed in this way, therefore the container -// does not allow all types of coordinator exceptions. On the other hand, -// an exception being listed here does not mean it is _always_ passed -// in an exception_container - it can be thrown in a regular fashion -// as well. -// -// It is advised to use this mechanism mainly for exceptions which can -// happen frequently, e.g. signalling timeouts, overloads or rate limits. -using coordinator_exception_container = utils::exception_container< - mutation_write_timeout_exception, - read_timeout_exception, - read_failure_exception ->; - -template -using coordinator_result = bo::result; - } diff --git a/service/pager/query_pager.hh b/service/pager/query_pager.hh index 389fad6f05..8ec48b1184 100644 --- a/service/pager/query_pager.hh +++ b/service/pager/query_pager.hh @@ -19,6 +19,7 @@ #include "service/query_state.hh" #include "utils/result.hh" #include "exceptions/exceptions.hh" +#include "exceptions/coordinator_result.hh" namespace service { diff --git a/service/storage_proxy.hh b/service/storage_proxy.hh index f3c1e731e4..022921e2b3 100644 --- a/service/storage_proxy.hh +++ b/service/storage_proxy.hh @@ -46,6 +46,7 @@ #include #include "query_ranges_to_vnodes.hh" #include "exceptions/exceptions.hh" +#include "exceptions/coordinator_result.hh" class reconcilable_result; class frozen_mutation_and_schema; diff --git a/transport/messages/result_message.hh b/transport/messages/result_message.hh index becd1d30b1..4e3c7129e4 100644 --- a/transport/messages/result_message.hh +++ b/transport/messages/result_message.hh @@ -19,6 +19,7 @@ #include "transport/messages/result_message_base.hh" #include "transport/event.hh" #include "exceptions/exceptions.hh" +#include "exceptions/coordinator_result.hh" #include #include diff --git a/transport/server.hh b/transport/server.hh index 1356859bb3..e78a0c2736 100644 --- a/transport/server.hh +++ b/transport/server.hh @@ -30,6 +30,7 @@ #include "cql3/query_options.hh" #include "transport/messages/result_message.hh" #include "utils/chunked_vector.hh" +#include "exceptions/coordinator_result.hh" namespace cql3 { diff --git a/utils/bloom_calculations.hh b/utils/bloom_calculations.hh index d0a9cb85e7..594f499e6a 100644 --- a/utils/bloom_calculations.hh +++ b/utils/bloom_calculations.hh @@ -13,6 +13,7 @@ #pragma once +#include #include "exceptions/exceptions.hh" namespace utils {