浏览代码

Merge pull request #260 from phillipCouto/expand_query_api

Expanded query and batch API to support retrieving the consistency level
Ben Hood 11 年之前
父节点
当前提交
80292ba2c9
共有 2 个文件被更改,包括 13 次插入0 次删除
  1. 1 0
      policies.go
  2. 12 0
      session.go

+ 1 - 0
policies.go

@@ -8,6 +8,7 @@ package gocql
 //exposes the correct functions for the retry policy logic to evaluate correctly.
 type RetryableQuery interface {
 	Attempts() int
+	GetConsistency() Consistency
 }
 
 // RetryPolicy interace is used by gocql to determine if a query can be attempted

+ 12 - 0
session.go

@@ -243,6 +243,12 @@ func (q *Query) Consistency(c Consistency) *Query {
 	return q
 }
 
+// GetConsistency returns the currently configured consistency level for
+// the query.
+func (q *Query) GetConsistency() Consistency {
+	return q.cons
+}
+
 // Trace enables tracing of this query. Look at the documentation of the
 // Tracer interface to learn more about tracing.
 func (q *Query) Trace(trace Tracer) *Query {
@@ -485,6 +491,12 @@ func (b *Batch) Latency() int64 {
 	return 0
 }
 
+// GetConsistency returns the currently configured consistency level for the batch
+// operation.
+func (b *Batch) GetConsistency() Consistency {
+	return b.Cons
+}
+
 // Query adds the query to the batch operation
 func (b *Batch) Query(stmt string, args ...interface{}) {
 	b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, Args: args})