3#include "data/cassandra/impl/ManagedObject.hpp"
4#include "util/Assert.hpp"
5#include "util/log/Logger.hpp"
18namespace data::cassandra::impl {
20enum class Provider { Cassandra, Keyspace };
23providerFromString(std::string
const& provider)
26 provider ==
"cassandra" || provider ==
"aws_keyspace",
27 "Provider type must be one of 'cassandra' or 'aws_keyspace'"
29 return provider ==
"cassandra" ? Provider::Cassandra : Provider::Keyspace;
38 static constexpr std::size_t kDEFAULT_CONNECTION_TIMEOUT = 10000;
39 static constexpr uint32_t kDEFAULT_MAX_WRITE_REQUESTS_OUTSTANDING = 10'000;
40 static constexpr uint32_t kDEFAULT_MAX_READ_REQUESTS_OUTSTANDING = 100'000;
41 static constexpr std::size_t kDEFAULT_BATCH_SIZE = 20;
42 static constexpr Provider kDEFAULT_PROVIDER = Provider::Cassandra;
48 std::string contactPoints =
"127.0.0.1";
49 std::optional<uint16_t> port;
64 std::chrono::milliseconds{kDEFAULT_CONNECTION_TIMEOUT};
73 uint32_t
threads = std::thread::hardware_concurrency();
115 ContactPoints{.contactPoints = std::string{contactPoints}, .port = std::nullopt};
129class Cluster :
public ManagedObject<CassCluster> {
137 setupConnection(
Settings const& settings);
146 setupCertificate(
Settings const& settings);
149 setupCredentials(
Settings const& settings);
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:77
Represents the configuration of a secure connection bundle.
Definition Cluster.hpp:55
Bundles all cassandra settings in one place.
Definition Cluster.hpp:37
std::chrono::milliseconds requestTimeout
Request timeout specified in milliseconds.
Definition Cluster.hpp:67
std::chrono::milliseconds connectionTimeout
Connect timeout specified in milliseconds.
Definition Cluster.hpp:63
Provider provider
Provider to know if we are using scylladb or keyspace.
Definition Cluster.hpp:88
std::optional< std::string > password
Password to match the username.
Definition Cluster.hpp:103
std::optional< std::string > username
Username/login.
Definition Cluster.hpp:99
uint32_t threads
The number of threads for the driver to pool.
Definition Cluster.hpp:73
uint32_t maxReadRequestsOutstanding
The maximum number of outstanding read requests at any given moment.
Definition Cluster.hpp:79
uint32_t maxWriteRequestsOutstanding
The maximum number of outstanding write requests at any given moment.
Definition Cluster.hpp:76
std::optional< std::string > certificate
SSL certificate.
Definition Cluster.hpp:95
uint32_t coreConnectionsPerHost
The number of connection per host to always have active.
Definition Cluster.hpp:82
std::variant< ContactPoints, SecureConnectionBundle > connectionInfo
Connection information; either ContactPoints or SecureConnectionBundle.
Definition Cluster.hpp:70
bool enableLog
Enables or disables cassandra driver logger.
Definition Cluster.hpp:60
std::size_t writeBatchSize
Size of batches when writing.
Definition Cluster.hpp:85
std::optional< uint32_t > queueSizeIO
Size of the IO queue.
Definition Cluster.hpp:91
static Settings defaultSettings()
Returns the default settings.
Definition Cluster.hpp:123
Settings withContactPoints(std::string_view contactPoints)
Creates a new Settings object as a copy of the current one with overridden contact points.
Definition Cluster.hpp:111