/**
* Create a new connection instance with the provided configuration
*/
public function __construct()
{
// Set up connection details
$builder = \Cassandra::cluster();
// Fetch configured port and set it, if it's provided
$port = config('cassandra.port');
if (!empty($port)) {
$builder->withPort($port);
}
// Fetch configured default page size and set it, if it's provided
$defaultPageSize = config('cassandra.defaultPageSize');
if (!empty($defaultPageSize)) {
$builder->withDefaultPageSize($defaultPageSize);
}
// Fetch configured default consistency level and set it, if it's provided
$defaultConsistency = config('cassandra.withDefaultConsistency');
if (!empty($defaultConsistency)) {
$builder->withDefaultConsistency($defaultConsistency);
}
// Set contact end points
call_user_func_array([$builder, "withContactPoints"], config('cassandra.contactpoints'));
// Connect to cluster
$this->cluster = $builder->build();
// Create a connect to the keyspace on cluster
$this->session = $this->cluster->connect(config('cassandra.keyspace'));
}