Files
scylladb/db/query_context.hh
Pavel Emelyanov 8a87c87824 db/system_keyspace: Move and use qctx::execute_cql_with_timeout()
This template call is only used by system keyspace paxos methods. All
those methods are no longer static and can use system_keyspace::_qp
reference to real query processor instead of global qctx. The
execute_cql_with_timeout() wrapper is moved to system_keyspace to make
it work

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-07-19 19:32:10 +03:00

42 lines
1.0 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include <memory>
#include <seastar/core/sharded.hh>
#include <seastar/core/distributed.hh>
#include <seastar/core/future.hh>
#include "cql3/query_processor.hh"
#include "cql3/query_options.hh"
#include "db/timeout_clock.hh"
#include "timeout_config.hh"
namespace service {
class storage_proxy;
}
namespace db {
struct query_context {
distributed<cql3::query_processor>& _qp;
query_context(distributed<cql3::query_processor>& qp) : _qp(qp) {}
template <typename... Args>
future<::shared_ptr<cql3::untyped_result_set>> execute_cql(sstring req, Args&&... args) {
return _qp.local().execute_internal(req, { data_value(std::forward<Args>(args))... }, cql3::query_processor::cache_internal::yes);
}
cql3::query_processor& qp() {
return _qp.local();
}
};
// This does not have to be thread local, because all cores will share the same context.
extern std::unique_ptr<query_context> qctx;
}