mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
Fix formatting
This commit is contained in:
@@ -39,17 +39,39 @@ namespace data {
|
||||
template <typename T>
|
||||
concept SomeBackendCounters = requires(T a) {
|
||||
typename T::PtrType;
|
||||
{ a.registerTooBusy() } -> std::same_as<void>;
|
||||
{ a.registerWriteSync(std::chrono::steady_clock::time_point{}) } -> std::same_as<void>;
|
||||
{ a.registerWriteSyncRetry() } -> std::same_as<void>;
|
||||
{ a.registerWriteStarted() } -> std::same_as<void>;
|
||||
{ a.registerWriteFinished(std::chrono::steady_clock::time_point{}) } -> std::same_as<void>;
|
||||
{ a.registerWriteRetry() } -> std::same_as<void>;
|
||||
{ a.registerReadStarted(std::uint64_t{}) } -> std::same_as<void>;
|
||||
{ a.registerReadFinished(std::chrono::steady_clock::time_point{}, std::uint64_t{}) } -> std::same_as<void>;
|
||||
{ a.registerReadRetry(std::uint64_t{}) } -> std::same_as<void>;
|
||||
{ a.registerReadError(std::uint64_t{}) } -> std::same_as<void>;
|
||||
{ a.report() } -> std::same_as<boost::json::object>;
|
||||
{
|
||||
a.registerTooBusy()
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerWriteSync(std::chrono::steady_clock::time_point{})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerWriteSyncRetry()
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerWriteStarted()
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerWriteFinished(std::chrono::steady_clock::time_point{})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerWriteRetry()
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerReadStarted(std::uint64_t{})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerReadFinished(std::chrono::steady_clock::time_point{}, std::uint64_t{})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerReadRetry(std::uint64_t{})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.registerReadError(std::uint64_t{})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.report()
|
||||
} -> std::same_as<boost::json::object>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -732,7 +732,9 @@ public:
|
||||
std::cend(keys),
|
||||
std::cbegin(objs),
|
||||
std::back_inserter(results),
|
||||
[](auto const& key, auto const& obj) { return LedgerObject{key, obj}; }
|
||||
[](auto const& key, auto const& obj) {
|
||||
return LedgerObject{key, obj};
|
||||
}
|
||||
);
|
||||
|
||||
return results;
|
||||
|
||||
@@ -41,11 +41,21 @@ namespace data::cassandra {
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeSettingsProvider = requires(T a) {
|
||||
{ a.getSettings() } -> std::same_as<Settings>;
|
||||
{ a.getKeyspace() } -> std::same_as<std::string>;
|
||||
{ a.getTablePrefix() } -> std::same_as<std::optional<std::string>>;
|
||||
{ a.getReplicationFactor() } -> std::same_as<uint16_t>;
|
||||
{ a.getTtl() } -> std::same_as<uint16_t>;
|
||||
{
|
||||
a.getSettings()
|
||||
} -> std::same_as<Settings>;
|
||||
{
|
||||
a.getKeyspace()
|
||||
} -> std::same_as<std::string>;
|
||||
{
|
||||
a.getTablePrefix()
|
||||
} -> std::same_as<std::optional<std::string>>;
|
||||
{
|
||||
a.getReplicationFactor()
|
||||
} -> std::same_as<uint16_t>;
|
||||
{
|
||||
a.getTtl()
|
||||
} -> std::same_as<uint16_t>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -61,18 +71,42 @@ concept SomeExecutionStrategy = requires(
|
||||
PreparedStatement prepared,
|
||||
boost::asio::yield_context token
|
||||
) {
|
||||
{ T(settings, handle) };
|
||||
{ a.sync() } -> std::same_as<void>;
|
||||
{ a.isTooBusy() } -> std::same_as<bool>;
|
||||
{ a.writeSync(statement) } -> std::same_as<ResultOrError>;
|
||||
{ a.writeSync(prepared) } -> std::same_as<ResultOrError>;
|
||||
{ a.write(prepared) } -> std::same_as<void>;
|
||||
{ a.write(std::move(statements)) } -> std::same_as<void>;
|
||||
{ a.read(token, prepared) } -> std::same_as<ResultOrError>;
|
||||
{ a.read(token, statement) } -> std::same_as<ResultOrError>;
|
||||
{ a.read(token, statements) } -> std::same_as<ResultOrError>;
|
||||
{ a.readEach(token, statements) } -> std::same_as<std::vector<Result>>;
|
||||
{ a.stats() } -> std::same_as<boost::json::object>;
|
||||
{
|
||||
T(settings, handle)
|
||||
};
|
||||
{
|
||||
a.sync()
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.isTooBusy()
|
||||
} -> std::same_as<bool>;
|
||||
{
|
||||
a.writeSync(statement)
|
||||
} -> std::same_as<ResultOrError>;
|
||||
{
|
||||
a.writeSync(prepared)
|
||||
} -> std::same_as<ResultOrError>;
|
||||
{
|
||||
a.write(prepared)
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.write(std::move(statements))
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.read(token, prepared)
|
||||
} -> std::same_as<ResultOrError>;
|
||||
{
|
||||
a.read(token, statement)
|
||||
} -> std::same_as<ResultOrError>;
|
||||
{
|
||||
a.read(token, statements)
|
||||
} -> std::same_as<ResultOrError>;
|
||||
{
|
||||
a.readEach(token, statements)
|
||||
} -> std::same_as<std::vector<Result>>;
|
||||
{
|
||||
a.stats()
|
||||
} -> std::same_as<boost::json::object>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -80,12 +114,18 @@ concept SomeExecutionStrategy = requires(
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeRetryPolicy = requires(T a, boost::asio::io_context ioc, CassandraError err, uint32_t attempt) {
|
||||
{ T(ioc) };
|
||||
{ a.shouldRetry(err) } -> std::same_as<bool>;
|
||||
{
|
||||
T(ioc)
|
||||
};
|
||||
{
|
||||
a.shouldRetry(err)
|
||||
} -> std::same_as<bool>;
|
||||
{
|
||||
a.retry([]() {})
|
||||
} -> std::same_as<void>;
|
||||
{ a.calculateDelay(attempt) } -> std::same_as<std::chrono::milliseconds>;
|
||||
{
|
||||
a.calculateDelay(attempt)
|
||||
} -> std::same_as<std::chrono::milliseconds>;
|
||||
};
|
||||
|
||||
} // namespace data::cassandra
|
||||
|
||||
@@ -121,8 +121,7 @@ public:
|
||||
// reinterpret_cast is needed here :'(
|
||||
auto const rc = bindBytes(reinterpret_cast<unsigned char const*>(value.data()), value.size());
|
||||
throwErrorIfNeeded(rc, "Bind string (as bytes)");
|
||||
} else if constexpr (std::is_same_v<DecayedType, UintTupleType> ||
|
||||
std::is_same_v<DecayedType, UintByteTupleType>) {
|
||||
} else if constexpr (std::is_same_v<DecayedType, UintTupleType> || std::is_same_v<DecayedType, UintByteTupleType>) {
|
||||
auto const rc = cass_statement_bind_tuple(*this, idx, Tuple{std::forward<Type>(value)});
|
||||
throwErrorIfNeeded(rc, "Bind tuple<uint32, uint32> or <uint32_t, ripple::uint256>");
|
||||
} else if constexpr (std::is_same_v<DecayedType, ByteVectorType>) {
|
||||
|
||||
@@ -117,8 +117,7 @@ LoadBalancer::LoadBalancer(
|
||||
"Failed to fetch ETL state from source = {} Please check the configuration and network",
|
||||
source->toString()
|
||||
));
|
||||
} else if (etlState_ && etlState_->networkID && stateOpt->networkID &&
|
||||
etlState_->networkID != stateOpt->networkID) {
|
||||
} else if (etlState_ && etlState_->networkID && stateOpt->networkID && etlState_->networkID != stateOpt->networkID) {
|
||||
checkOnETLFailure(fmt::format(
|
||||
"ETL sources must be on the same network. Source network id = {} does not match others network id = {}",
|
||||
*(stateOpt->networkID),
|
||||
|
||||
@@ -33,7 +33,9 @@ namespace feed::impl {
|
||||
|
||||
template <typename T>
|
||||
concept Hashable = requires(T a) {
|
||||
{ std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
|
||||
{
|
||||
std::hash<T>{}(a)
|
||||
} -> std::convertible_to<std::size_t>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,8 +77,8 @@ struct Status {
|
||||
std::optional<boost::json::object> extraInfo;
|
||||
|
||||
Status() = default;
|
||||
/* implicit */ Status(CombinedError code) : code(code) {};
|
||||
Status(CombinedError code, boost::json::object&& extraInfo) : code(code), extraInfo(std::move(extraInfo)) {};
|
||||
/* implicit */ Status(CombinedError code) : code(code){};
|
||||
Status(CombinedError code, boost::json::object&& extraInfo) : code(code), extraInfo(std::move(extraInfo)){};
|
||||
|
||||
// HACK. Some rippled handlers explicitly specify errors.
|
||||
// This means that we have to be able to duplicate this functionality.
|
||||
|
||||
@@ -35,7 +35,9 @@ namespace rpc {
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeRequirement = requires(T a, boost::json::value lval) {
|
||||
{ a.verify(lval, std::string{}) } -> std::same_as<MaybeError>;
|
||||
{
|
||||
a.verify(lval, std::string{})
|
||||
} -> std::same_as<MaybeError>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -43,7 +45,9 @@ concept SomeRequirement = requires(T a, boost::json::value lval) {
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeModifier = requires(T a, boost::json::value lval) {
|
||||
{ a.modify(lval, std::string{}) } -> std::same_as<MaybeError>;
|
||||
{
|
||||
a.modify(lval, std::string{})
|
||||
} -> std::same_as<MaybeError>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,7 +61,9 @@ concept SomeProcessor = (SomeRequirement<T> or SomeModifier<T>);
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeContextProcessWithInput = requires(T a, typename T::Input in, typename T::Output out, Context const& ctx) {
|
||||
{ a.process(in, ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
|
||||
{
|
||||
a.process(in, ctx)
|
||||
} -> std::same_as<HandlerReturnType<decltype(out)>>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -65,7 +71,9 @@ concept SomeContextProcessWithInput = requires(T a, typename T::Input in, typena
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeContextProcessWithoutInput = requires(T a, typename T::Output out, Context const& ctx) {
|
||||
{ a.process(ctx) } -> std::same_as<HandlerReturnType<decltype(out)>>;
|
||||
{
|
||||
a.process(ctx)
|
||||
} -> std::same_as<HandlerReturnType<decltype(out)>>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -73,7 +81,9 @@ concept SomeContextProcessWithoutInput = requires(T a, typename T::Output out, C
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeHandlerWithInput = requires(T a, uint32_t version) {
|
||||
{ a.spec(version) } -> std::same_as<RpcSpecConstRef>;
|
||||
{
|
||||
a.spec(version)
|
||||
} -> std::same_as<RpcSpecConstRef>;
|
||||
} and SomeContextProcessWithInput<T> and boost::json::has_value_to<typename T::Input>::value;
|
||||
|
||||
/**
|
||||
@@ -87,6 +97,6 @@ concept SomeHandlerWithoutInput = SomeContextProcessWithoutInput<T>;
|
||||
*/
|
||||
template <typename T>
|
||||
concept SomeHandler =
|
||||
(SomeHandlerWithInput<T> or SomeHandlerWithoutInput<T>) and boost::json::has_value_from<typename T::Output>::value;
|
||||
(SomeHandlerWithInput<T> or SomeHandlerWithoutInput<T>)and boost::json::has_value_from<typename T::Output>::value;
|
||||
|
||||
} // namespace rpc
|
||||
|
||||
@@ -29,9 +29,15 @@ template <typename T>
|
||||
concept SomeCounterImpl = requires(T a) {
|
||||
typename std::remove_cvref_t<T>::ValueType;
|
||||
requires SomeNumberType<typename std::remove_cvref_t<T>::ValueType>;
|
||||
{ a.add(typename std::remove_cvref_t<T>::ValueType{1}) } -> std::same_as<void>;
|
||||
{ a.set(typename std::remove_cvref_t<T>::ValueType{1}) } -> std::same_as<void>;
|
||||
{ a.value() } -> SomeNumberType;
|
||||
{
|
||||
a.add(typename std::remove_cvref_t<T>::ValueType{1})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.set(typename std::remove_cvref_t<T>::ValueType{1})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
a.value()
|
||||
} -> SomeNumberType;
|
||||
};
|
||||
|
||||
template <SomeNumberType NumberType>
|
||||
|
||||
@@ -38,9 +38,15 @@ template <typename T>
|
||||
concept SomeHistogramImpl = requires(T t) {
|
||||
typename std::remove_cvref_t<T>::ValueType;
|
||||
requires SomeNumberType<typename std::remove_cvref_t<T>::ValueType>;
|
||||
{ t.observe(typename std::remove_cvref_t<T>::ValueType{1}) } -> std::same_as<void>;
|
||||
{ t.setBuckets(std::vector<typename std::remove_cvref_t<T>::ValueType>{}) } -> std::same_as<void>;
|
||||
{ t.serializeValue(std::string{}, std::string{}, std::declval<OStream&>()) } -> std::same_as<void>;
|
||||
{
|
||||
t.observe(typename std::remove_cvref_t<T>::ValueType{1})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
t.setBuckets(std::vector<typename std::remove_cvref_t<T>::ValueType>{})
|
||||
} -> std::same_as<void>;
|
||||
{
|
||||
t.serializeValue(std::string{}, std::string{}, std::declval<OStream&>())
|
||||
} -> std::same_as<void>;
|
||||
};
|
||||
|
||||
template <SomeNumberType NumberType>
|
||||
|
||||
@@ -33,7 +33,9 @@ namespace web {
|
||||
template <typename T>
|
||||
concept SomeResolver = requires(T t) {
|
||||
std::is_default_constructible_v<T>;
|
||||
{ t.resolve(std::string_view{}, std::string_view{}) } -> std::same_as<std::vector<std::string>>;
|
||||
{
|
||||
t.resolve(std::string_view{}, std::string_view{})
|
||||
} -> std::same_as<std::vector<std::string>>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,9 @@ template <typename T>
|
||||
concept SomeServerHandler =
|
||||
requires(T handler, std::string req, std::shared_ptr<ConnectionBase> ws, boost::beast::error_code ec) {
|
||||
// the callback when server receives a request
|
||||
{ handler(req, ws) };
|
||||
{
|
||||
handler(req, ws)
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace web
|
||||
|
||||
@@ -106,7 +106,7 @@ struct MockHandle {
|
||||
};
|
||||
|
||||
struct FakeRetryPolicy {
|
||||
FakeRetryPolicy(boost::asio::io_context&) {}; // required by concept
|
||||
FakeRetryPolicy(boost::asio::io_context&){}; // required by concept
|
||||
|
||||
static std::chrono::milliseconds
|
||||
calculateDelay(uint32_t /* attempt */)
|
||||
|
||||
Reference in New Issue
Block a user