@@ -523,6 +523,7 @@ func (s *Session) Close() {
523523 s .sessionStateMu .Unlock ()
524524}
525525
526+ // Closed returns true only after you call Session.Close().
526527func (s * Session ) Closed () bool {
527528 s .sessionStateMu .RLock ()
528529 closed := s .isClosed
@@ -1000,6 +1001,7 @@ func (q *Query) Attempts() int {
10001001 return q .metrics .attempts ()
10011002}
10021003
1004+ // AddAttempts adds number of attempts i for given host.
10031005func (q * Query ) AddAttempts (i int , host * HostInfo ) {
10041006 q .metrics .attempt (i , 0 , host , false )
10051007}
@@ -1009,6 +1011,7 @@ func (q *Query) Latency() int64 {
10091011 return q .metrics .latency ()
10101012}
10111013
1014+ // AddLatency adds latency for given host.
10121015func (q * Query ) AddLatency (l int64 , host * HostInfo ) {
10131016 q .metrics .attempt (0 , time .Duration (l )* time .Nanosecond , host , false )
10141017}
@@ -1038,6 +1041,8 @@ func (q *Query) CustomPayload(customPayload map[string][]byte) *Query {
10381041 return q
10391042}
10401043
1044+ // Context returns the context of the Query.
1045+ // Returns the context.Background() if Query.Context == nil
10411046func (q * Query ) Context () context.Context {
10421047 if q .context == nil {
10431048 return context .Background ()
@@ -1115,11 +1120,6 @@ func (q *Query) WithContext(ctx context.Context) *Query {
11151120 return & q2
11161121}
11171122
1118- // Deprecate: does nothing, cancel the context passed to WithContext
1119- func (q * Query ) Cancel () {
1120- // TODO: delete
1121- }
1122-
11231123func (q * Query ) execute (ctx context.Context , conn * Conn ) * Iter {
11241124 return conn .executeQuery (ctx , q )
11251125}
@@ -1743,6 +1743,7 @@ func (n *nextIter) fetch() *Iter {
17431743 return n .next
17441744}
17451745
1746+ // Batch represents a group of CQL statements that can be executed together.
17461747type Batch struct {
17471748 Type BatchType
17481749 Entries []BatchEntry
@@ -1809,6 +1810,7 @@ func (b *Batch) Observer(observer BatchObserver) *Batch {
18091810 return b
18101811}
18111812
1813+ // Keyspace returns the keyspace the batch will be executed against.
18121814func (b * Batch ) Keyspace () string {
18131815 return b .keyspace
18141816}
@@ -1823,6 +1825,7 @@ func (b *Batch) Attempts() int {
18231825 return b .metrics .attempts ()
18241826}
18251827
1828+ // AddAttempts adds number of attempts i for given host.
18261829func (b * Batch ) AddAttempts (i int , host * HostInfo ) {
18271830 b .metrics .attempt (i , 0 , host , false )
18281831}
@@ -1832,6 +1835,7 @@ func (b *Batch) Latency() int64 {
18321835 return b .metrics .latency ()
18331836}
18341837
1838+ // AddLatency adds latency for given host.
18351839func (b * Batch ) AddLatency (l int64 , host * HostInfo ) {
18361840 b .metrics .attempt (0 , time .Duration (l )* time .Nanosecond , host , false )
18371841}
@@ -1848,13 +1852,16 @@ func (b *Batch) SetConsistency(c Consistency) {
18481852 b .Cons = c
18491853}
18501854
1855+ // Context returns the context of the Batch.
1856+ // Returns the context.Background() if Batch.Context == nil
18511857func (b * Batch ) Context () context.Context {
18521858 if b .context == nil {
18531859 return context .Background ()
18541860 }
18551861 return b .context
18561862}
18571863
1864+ // IsIdempotent returns false if one of the Batch.Entries are not Idempotent.
18581865func (b * Batch ) IsIdempotent () bool {
18591866 for _ , entry := range b .Entries {
18601867 if ! entry .Idempotent {
@@ -1868,6 +1875,7 @@ func (b *Batch) speculativeExecutionPolicy() SpeculativeExecutionPolicy {
18681875 return b .spec
18691876}
18701877
1878+ // SpeculativeExecutionPolicy sets SpeculativeExecutionPolicy and returns Batch
18711879func (b * Batch ) SpeculativeExecutionPolicy (sp SpeculativeExecutionPolicy ) * Batch {
18721880 b .spec = sp
18731881 return b
@@ -1912,11 +1920,6 @@ func (b *Batch) WithContext(ctx context.Context) *Batch {
19121920 return & b2
19131921}
19141922
1915- // Deprecate: does nothing, cancel the context passed to WithContext
1916- func (* Batch ) Cancel () {
1917- // TODO: delete
1918- }
1919-
19201923// Size returns the number of batch statements to be executed by the batch operation.
19211924func (b * Batch ) Size () int {
19221925 return len (b .Entries )
@@ -1987,6 +1990,12 @@ func (b *Batch) attempt(keyspace string, end, start time.Time, iter *Iter, host
19871990 })
19881991}
19891992
1993+ // GetRoutingKey gets the routing key to use for routing this batch. If
1994+ // a routing key has not been explicitly set, then the routing key will
1995+ // be constructed if possible using the keyspace's schema and the batch
1996+ // info for this batch entry statement. If the routing key cannot be determined
1997+ // then nil will be returned with no error. On any error condition,
1998+ // an error description will be returned.
19901999func (b * Batch ) GetRoutingKey () ([]byte , error ) {
19912000 if b .routingKey != nil {
19922001 return b .routingKey , nil
@@ -2065,6 +2074,7 @@ const (
20652074 CounterBatch BatchType = 2
20662075)
20672076
2077+ // BatchEntry represents a single query inside a batch operation
20682078type BatchEntry struct {
20692079 Stmt string
20702080 Args []interface {}
0 commit comments