forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.hh
92 lines (81 loc) · 3.2 KB
/
options.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Copyright (C) 2019 pengjian.uestc @ gmail.com
*/
/*
* This file is part of Scylla.
*
* Scylla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scylla is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdexcept>
#include "timeout_config.hh"
#include "db/consistency_level_type.hh"
#include "seastar/core/sstring.hh"
#include "seastar/net/socket_defs.hh"
#include "schema_fwd.hh"
#include "service/client_state.hh"
#include "auth/service.hh"
namespace service {
class storage_proxy;
}
namespace redis {
class redis_options {
sstring _ks_name;
const db::consistency_level _read_consistency;
const db::consistency_level _write_consistency;
const timeout_config& _timeout_config;
service::client_state _client_state;
size_t _total_redis_db_count;
public:
explicit redis_options(const db::consistency_level rcl,
const db::consistency_level wcl,
const timeout_config& tc,
auth::service& auth,
const socket_address addr,
size_t total_redis_db_count)
:_ks_name("REDIS_0")
,_read_consistency(rcl)
,_write_consistency(wcl)
,_timeout_config(tc)
,_client_state(service::client_state::external_tag{}, auth, nullptr, tc, addr)
,_total_redis_db_count(total_redis_db_count)
{
}
explicit redis_options(const sstring& ks_name,
const db::consistency_level rcl,
const db::consistency_level wcl,
const timeout_config& tc,
auth::service& auth,
const socket_address addr,
size_t total_redis_db_count)
:_ks_name(ks_name)
,_read_consistency(rcl)
,_write_consistency(wcl)
,_timeout_config(tc)
,_client_state(service::client_state::external_tag{}, auth, nullptr, tc, addr)
,_total_redis_db_count(total_redis_db_count)
{
}
const db::consistency_level get_read_consistency_level() const { return _read_consistency; }
const db::consistency_level get_write_consistency_level() const { return _write_consistency; }
const timeout_config& get_timeout_config() const { return _timeout_config; }
const db::timeout_clock::duration get_read_timeout() const { return _timeout_config.read_timeout; }
const db::timeout_clock::duration get_write_timeout() const { return _timeout_config.write_timeout; }
const sstring& get_keyspace_name() const { return _ks_name; }
service::client_state& get_client_state() { return _client_state; }
void set_keyspace_name(const sstring ks_name) { _ks_name = ks_name; }
size_t get_total_redis_db_count() const { return _total_redis_db_count; }
};
schema_ptr get_schema(service::storage_proxy& proxy, const sstring& ks_name, const sstring& cf_name);
}