service: add timeout config to client state
Future patches will use this per-connection timeout config to allow setting different timeouts for each session, based on roles.
This commit is contained in:
@@ -60,7 +60,7 @@ public:
|
||||
,_read_consistency(rcl)
|
||||
,_write_consistency(wcl)
|
||||
,_timeout_config(tc)
|
||||
,_client_state(service::client_state::external_tag{}, auth, addr)
|
||||
,_client_state(service::client_state::external_tag{}, auth, tc, addr)
|
||||
,_total_redis_db_count(total_redis_db_count)
|
||||
{
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
,_read_consistency(rcl)
|
||||
,_write_consistency(wcl)
|
||||
,_timeout_config(tc)
|
||||
,_client_state(service::client_state::external_tag{}, auth, addr)
|
||||
,_client_state(service::client_state::external_tag{}, auth, tc, addr)
|
||||
,_total_redis_db_count(total_redis_db_count)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "auth/service.hh"
|
||||
#include "exceptions/exceptions.hh"
|
||||
#include "unimplemented.hh"
|
||||
#include "timeout_config.hh"
|
||||
#include "timestamp.hh"
|
||||
#include "db_clock.hh"
|
||||
#include "database_fwd.hh"
|
||||
@@ -88,10 +89,17 @@ public:
|
||||
};
|
||||
private:
|
||||
client_state(const client_state* cs, seastar::sharded<auth::service>* auth_service)
|
||||
: _keyspace(cs->_keyspace), _user(cs->_user), _auth_state(cs->_auth_state),
|
||||
_is_internal(cs->_is_internal), _is_thrift(cs->_is_thrift), _remote_address(cs->_remote_address),
|
||||
_auth_service(auth_service ? &auth_service->local() : nullptr),
|
||||
_enabled_protocol_extensions(cs->_enabled_protocol_extensions) {}
|
||||
: _keyspace(cs->_keyspace)
|
||||
, _user(cs->_user)
|
||||
, _auth_state(cs->_auth_state)
|
||||
, _is_internal(cs->_is_internal)
|
||||
, _is_thrift(cs->_is_thrift)
|
||||
, _remote_address(cs->_remote_address)
|
||||
, _auth_service(auth_service ? &auth_service->local() : nullptr)
|
||||
, _default_timeout_config(cs->_default_timeout_config)
|
||||
, _timeout_config(cs->_timeout_config)
|
||||
, _enabled_protocol_extensions(cs->_enabled_protocol_extensions)
|
||||
{}
|
||||
friend client_state_for_another_shard;
|
||||
private:
|
||||
sstring _keyspace;
|
||||
@@ -136,6 +144,10 @@ private:
|
||||
// Only populated for external client state.
|
||||
auth::service* _auth_service{nullptr};
|
||||
|
||||
// For restoring default values in the timeout config
|
||||
timeout_config _default_timeout_config;
|
||||
timeout_config _timeout_config;
|
||||
|
||||
public:
|
||||
struct internal_tag {};
|
||||
struct external_tag {};
|
||||
@@ -162,11 +174,13 @@ public:
|
||||
_driver_version = std::move(driver_version);
|
||||
}
|
||||
|
||||
client_state(external_tag, auth::service& auth_service, const socket_address& remote_address = socket_address(), bool thrift = false)
|
||||
client_state(external_tag, auth::service& auth_service, timeout_config timeout_config, const socket_address& remote_address = socket_address(), bool thrift = false)
|
||||
: _is_internal(false)
|
||||
, _is_thrift(thrift)
|
||||
, _remote_address(remote_address)
|
||||
, _auth_service(&auth_service) {
|
||||
, _auth_service(&auth_service)
|
||||
, _default_timeout_config(timeout_config)
|
||||
, _timeout_config(timeout_config) {
|
||||
if (!auth_service.underlying_authenticator().require_authentication()) {
|
||||
_user = auth::authenticated_user();
|
||||
}
|
||||
@@ -180,10 +194,16 @@ public:
|
||||
return _remote_address.port();
|
||||
}
|
||||
|
||||
const timeout_config& get_timeout_config() const {
|
||||
return _timeout_config;
|
||||
}
|
||||
|
||||
client_state(internal_tag)
|
||||
: _keyspace("system")
|
||||
, _is_internal(true)
|
||||
, _is_thrift(false)
|
||||
, _default_timeout_config(infinite_timeout_config)
|
||||
, _timeout_config(infinite_timeout_config)
|
||||
{}
|
||||
|
||||
client_state(const client_state&) = delete;
|
||||
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
service::client_state client_state;
|
||||
|
||||
core_local_state(auth::service& auth_service)
|
||||
: client_state(service::client_state::external_tag{}, auth_service)
|
||||
: client_state(service::client_state::external_tag{}, auth_service, infinite_timeout_config)
|
||||
{
|
||||
client_state.set_login(auth::authenticated_user(testing_superuser));
|
||||
}
|
||||
|
||||
@@ -201,9 +201,9 @@ enum class query_order { no, yes };
|
||||
class thrift_handler : public CassandraCobSvIf {
|
||||
distributed<database>& _db;
|
||||
distributed<cql3::query_processor>& _query_processor;
|
||||
::timeout_config _timeout_config;
|
||||
service::client_state _client_state;
|
||||
service::query_state _query_state;
|
||||
::timeout_config _timeout_config;
|
||||
private:
|
||||
template <typename Cob, typename Func>
|
||||
void
|
||||
@@ -220,9 +220,9 @@ public:
|
||||
explicit thrift_handler(distributed<database>& db, distributed<cql3::query_processor>& qp, auth::service& auth_service, ::timeout_config timeout_config)
|
||||
: _db(db)
|
||||
, _query_processor(qp)
|
||||
, _client_state(service::client_state::external_tag{}, auth_service, socket_address(), true)
|
||||
, _query_state(_client_state, /*FIXME: pass real permit*/empty_service_permit())
|
||||
, _timeout_config(timeout_config)
|
||||
, _client_state(service::client_state::external_tag{}, auth_service, _timeout_config, socket_address(), true)
|
||||
, _query_state(_client_state, /*FIXME: pass real permit*/empty_service_permit())
|
||||
{ }
|
||||
|
||||
const sstring& current_keyspace() const {
|
||||
|
||||
@@ -608,7 +608,7 @@ cql_server::connection::connection(cql_server& server, socket_address server_add
|
||||
, _fd(std::move(fd))
|
||||
, _read_buf(_fd.input())
|
||||
, _write_buf(_fd.output())
|
||||
, _client_state(service::client_state::external_tag{}, server._auth_service, addr)
|
||||
, _client_state(service::client_state::external_tag{}, server._auth_service, server.timeout_config(), addr)
|
||||
{
|
||||
++_server._total_connections;
|
||||
++_server._current_connections;
|
||||
|
||||
Reference in New Issue
Block a user