Set consistency level with CQL3 #3

Open
wants to merge 3 commits into
from

Projects

None yet

3 participants

@ottbot

Manage the consistency level on queries per connection, and temporarily change it within a block.

@ottbot ottbot referenced this pull request in kreynolds/cassandra-cql Apr 12, 2013
Merged

Thrift bindings etc. for 1.2 #39

@jnunemaker jnunemaker commented on the diff Apr 12, 2013
lib/cassandra-cql/database.rb
@@ -131,5 +136,33 @@ def login!(username, password)
@auth_request = request
ret
end
+
+ def with_consistency(level)
+ previous_level = @consistency_name
+ self.consistency = level
@jnunemaker
jnunemaker Apr 12, 2013

Correct me if I'm wrong, but this wouldn't be thread safe.

@jnunemaker jnunemaker commented on the diff Apr 12, 2013
lib/cassandra-cql/database.rb
@@ -131,5 +136,33 @@ def login!(username, password)
@auth_request = request
ret
end
+
+ def with_consistency(level)
+ previous_level = @consistency_name
+ self.consistency = level
+ yield
+ self.consistency = previous_level
+ end
+
+ def consistency
+ @consistency ||= get_consistency(:quorum)
@jnunemaker
jnunemaker Apr 12, 2013

This also will cause thread safety issues.

@outoftime
Owner

I'm not sure we need to worry about thread-safety -- are the underlying Thrift connections thread-safe? Methinks not, in which case we can assume threads shouldn't be sharing a Database instance anyway... but can someone confirm or deny?

@ottbot
@outoftime outoftime referenced this pull request in kreynolds/cassandra-cql Nov 30, 2013
Open

Set CQL3 consistency per connection #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment