Add alternative way to supply username/password to CassandraClientOptions
Closed this issue · 3 comments
Adding the possibility to add username/password to the options might make the API a bit easier (opinion). I wouldn't mind to work on the implementation if agreed upon.
Current solution looks something like this:
val options = CassandraClientOptions()
.dataStaxClusterBuilder().withCredentials(
settings.getString("cassandra.username"),
settings.getString("cassandra.password")
)
val client = cassandra = CassandraClient.createShared(vertx, CassandraClientOptions(options))
While we maybe want to do something like this:
val options = CassandraClientOptions(options)
.setUsername("username")
.setPassword("password")
val client = cassandra = CassandraClient.createShared(vertx, options)
@zwennesm sounds legit to me to add the params most often used straight in the dataobject. Out of curiosity, which params do you currently use in you project?
I've only used the Cassandra connector in two projects now so i'm not a speaking with a lot of experience but basically in both implementations it comes down to something like this:
val options = CassandraClientOptions()
.setKeyspace(settings.getString("cassandra.keyspace"))
.setContactPoints(contactPoints))
.dataStaxClusterBuilder().withCredentials(
settings.getString("cassandra.username"),
settings.getString("cassandra.password")
).withTimestampGenerator(AtomicMonotonicTimestampGenerator())
The timestamp generator addition is useful when you don't want to add a TIMESTAMP to each query function or see this in the application logs for each query:
125424 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
125724 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
125955 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
126223 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
126531 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
126754 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
127009 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
127242 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
127462 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
127723 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
128144 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
128626 [vert.x-worker-thread-7] INFO com.datastax.driver.core.ClockFactory - Using native clock to generate timestamps.
https://docs.datastax.com/en/developer/java-driver/2.1/manual/query_timestamps/