added default consistency level for sessions#50
Conversation
|
I +1 the idea to have a default consistency level but I think it'd be more appropriate to have it on the Cluster builder rather than on the Session object as one normally don't need to modify it after startup. |
|
I thought i would be nice to be able to use one Cluster for the application and different Sessions with different CLs for different modules. |
* A default consistency level can be set for all new queries created by the session. * A default cossistency level can be set for all new sessions created by the cluster. * The default consistency level, if not set by setDefaultConsistencyLevel, is ConsistencyLevel.ONE.
|
i made a rebase, moved the consistency tests out of the session tests and added get/setDefaultConsistencyLevel to the cluster |
|
should the consistency be part of "Configuration getConfiguration()" or only be set when calling "public Cluster build()"? |
|
My own opinion is that having this global would be enough and having it set once by the builder only should be enough. We had some though about this and it is very unclear than setting a default consistency at the session level is where you want to put it in general. And I don't want to risk people using 2 different sessions just to have different consistency level, because that would be a bad use of ressources. I can buy that you'd want to set a different global CL though. To be clear, I do not pretend that setting the CL for every query is fun, but I'm not convinced the session level is the right level of default for that. I think that higher level API (say an object mapper) may be a better place to have meaningful consistency defaults. And while I could be wrong and may change my opinion when we have more experience with the driver, for now, I'd rather keep the default CL as a global config only rather than feature creeping too early. A part of me also think that the CL is an important part of the query that it's probably not such a bad thing to have it written down with most queries, even if it's a bit verbose. |
|
Based on the experience with the driver, so far, setting the CL for each query was not such a pain, especially when you are using prepared statements. I'm using different CL for read, write or delete operations, so a default is useful but really not a big deal if is missing. |
|
For info, the 2.0 version of the driver will allow to change the default CL level globally. |
Previously, when determining whether a statement should use simple or extended query styles, only the first line was considered. Obviously, multiline SQL statements are reasonable, so this change updates the code to look at all lines. [resolves apache#50] Signed-off-by: Ben Hale <bhale@pivotal.io>
A default consistency level can be set to be used for all new queries created by the Session.
This overwrites the default of ConsistencyLevel.ONE without the need to set it for every query manually.