|
@@ -96,7 +96,7 @@ func (s *Session) Query(stmt string, values ...interface{}) *Query {
|
|
|
s.mu.RLock()
|
|
s.mu.RLock()
|
|
|
qry := &Query{stmt: stmt, values: values, cons: s.cons,
|
|
qry := &Query{stmt: stmt, values: values, cons: s.cons,
|
|
|
session: s, pageSize: s.pageSize, trace: s.trace,
|
|
session: s, pageSize: s.pageSize, trace: s.trace,
|
|
|
- prefetch: s.prefetch, rt: s.cfg.RetryPolicy}
|
|
|
|
|
|
|
+ prefetch: s.prefetch, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency}
|
|
|
s.mu.RUnlock()
|
|
s.mu.RUnlock()
|
|
|
return qry
|
|
return qry
|
|
|
}
|
|
}
|
|
@@ -372,6 +372,7 @@ type Query struct {
|
|
|
binding func(q *QueryInfo) ([]interface{}, error)
|
|
binding func(q *QueryInfo) ([]interface{}, error)
|
|
|
attempts int
|
|
attempts int
|
|
|
totalLatency int64
|
|
totalLatency int64
|
|
|
|
|
+ serialCons SerialConsistency
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Attempts returns the number of times the query was executed.
|
|
//Attempts returns the number of times the query was executed.
|
|
@@ -517,6 +518,16 @@ func (q *Query) Bind(v ...interface{}) *Query {
|
|
|
return q
|
|
return q
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// SerialConsistency sets the consistencyc level for the
|
|
|
|
|
+// serial phase of conditional updates. That consitency can only be
|
|
|
|
|
+// either SERIAL or LOCAL_SERIAL and if not present, it defaults to
|
|
|
|
|
+// SERIAL. This option will be ignored for anything else that a
|
|
|
|
|
+// conditional update/insert.
|
|
|
|
|
+func (q *Query) SerialConsistency(cons SerialConsistency) *Query {
|
|
|
|
|
+ q.serialCons = cons
|
|
|
|
|
+ return q
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// Exec executes the query without returning any rows.
|
|
// Exec executes the query without returning any rows.
|
|
|
func (q *Query) Exec() error {
|
|
func (q *Query) Exec() error {
|
|
|
iter := q.Iter()
|
|
iter := q.Iter()
|
|
@@ -713,6 +724,7 @@ type Batch struct {
|
|
|
rt RetryPolicy
|
|
rt RetryPolicy
|
|
|
attempts int
|
|
attempts int
|
|
|
totalLatency int64
|
|
totalLatency int64
|
|
|
|
|
+ serialCons SerialConsistency
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// NewBatch creates a new batch operation without defaults from the cluster
|
|
// NewBatch creates a new batch operation without defaults from the cluster
|
|
@@ -722,7 +734,7 @@ func NewBatch(typ BatchType) *Batch {
|
|
|
|
|
|
|
|
// NewBatch creates a new batch operation using defaults defined in the cluster
|
|
// NewBatch creates a new batch operation using defaults defined in the cluster
|
|
|
func (s *Session) NewBatch(typ BatchType) *Batch {
|
|
func (s *Session) NewBatch(typ BatchType) *Batch {
|
|
|
- return &Batch{Type: typ, rt: s.cfg.RetryPolicy}
|
|
|
|
|
|
|
+ return &Batch{Type: typ, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Attempts returns the number of attempts made to execute the batch.
|
|
// Attempts returns the number of attempts made to execute the batch.
|
|
@@ -767,6 +779,18 @@ func (b *Batch) Size() int {
|
|
|
return len(b.Entries)
|
|
return len(b.Entries)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// SerialConsistency sets the consistencyc level for the
|
|
|
|
|
+// serial phase of conditional updates. That consitency can only be
|
|
|
|
|
+// either SERIAL or LOCAL_SERIAL and if not present, it defaults to
|
|
|
|
|
+// SERIAL. This option will be ignored for anything else that a
|
|
|
|
|
+// conditional update/insert.
|
|
|
|
|
+//
|
|
|
|
|
+// Only available for protocol 3 and above
|
|
|
|
|
+func (b *Batch) SerialConsistency(cons SerialConsistency) *Batch {
|
|
|
|
|
+ b.serialCons = cons
|
|
|
|
|
+ return b
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
type BatchType byte
|
|
type BatchType byte
|
|
|
|
|
|
|
|
const (
|
|
const (
|