Reputation: 31546
I have the following code written on the datastax driver to establish a cassandra connection.
val cluster = Cluster.builder()
.withCompression(ProtocolOptions.Compression.LZ4)
.addContactPoints(List("a", "b").asJava)
.withCredentials("foo", "bar")
.withPort(1111)
.withProtocolVersion(ProtocolVersion.V4)
.withPoolingOptions(new PoolingOptions()
.setConnectionsPerHost(HostDistance.LOCAL, 1, 12)
.setConnectionsPerHost(HostDistance.REMOTE, 1, 12)
.setMaxRequestsPerConnection(HostDistance.LOCAL, 1028)
.setMaxRequestsPerConnection(HostDistance.REMOTE, 1028)
)
.withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.QUORUM))
I am trying to migrate this code to start using PhantomDSL.
I want to build a PhantomDSL CassandraConnection with all the options like the one above.
I looked in the code here
and tried
val phantomConnection = new CassandraConnection("foo", cluster, false)
The error I get is
[error] MyConnection.scala:37: type mismatch;
[error] found : com.datastax.driver.core.Cluster.Builder
[error] required: com.outworkers.phantom.connectors.ClusterBuilder
[error] (which expands to) com.datastax.driver.core.Cluster.Builder => com.datastax.driver.core.Cluster.Builder
[error] Error occurred in an application involving default arguments.
[error] new CassandraConnection("foo", cluster, false)
[error] ^
Upvotes: 3
Views: 261
Reputation: 28511
Simply use the native _.withClusterBuilder
method which will allow you to achieve what you want. Apologies for the late reply, we monitor questions to this tag but for some reason this never made it to any of our inboxes.
object Connector {
val default: CassandraConnection = ContactPoint.local
.withClusterBuilder(
_.withCompression(ProtocolOptions.Compression.LZ4)
.withCredentials("foo", "bar")
.withPort(1111)
.withProtocolVersion(ProtocolVersion.V4)
).noHeartbeat().keySpace(
KeySpace("phantom").ifNotExists().`with`(
replication eqs SimpleStrategy.replication_factor(1)
)
)
}
Upvotes: 3