Skip to content

Commit 96de34e

Browse files
committed
Remove gocql.Conn from gocql.QueryAttempt
Replace with read-only addr fields.
1 parent ca8e0a4 commit 96de34e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

query_executor.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package gocql
2626

2727
import (
2828
"context"
29+
"net"
2930
"sync"
3031
"time"
3132
)
@@ -56,10 +57,12 @@ type queryExecutor struct {
5657
type QueryAttempt struct {
5758
// The query to execute, either a *gocql.Query or *gocql.Batch.
5859
Query ExecutableQuery
59-
// The connection used to execute the query.
60-
Conn *Conn
6160
// The host that will receive the query.
6261
Host *HostInfo
62+
// The local address of the connection used to execute the query.
63+
LocalAddr net.Addr
64+
// The remote address of the connection used to execute the query.
65+
RemoteAddr net.Addr
6366
// The number of previous query attempts. 0 for the initial attempt, 1 for the first retry, etc.
6467
Attempts int
6568
}
@@ -88,14 +91,15 @@ func (q *queryExecutor) attemptQuery(ctx context.Context, qry ExecutableQuery, c
8891
// Propagate interceptor context modifications.
8992
_ctx := ctx
9093
attempt := QueryAttempt{
91-
Query: qry,
92-
Conn: conn,
93-
Host: conn.host,
94-
Attempts: qry.Attempts(),
94+
Query: qry,
95+
Host: conn.host,
96+
LocalAddr: conn.conn.LocalAddr(),
97+
RemoteAddr: conn.conn.RemoteAddr(),
98+
Attempts: qry.Attempts(),
9599
}
96100
iter, err = q.interceptor.Intercept(_ctx, attempt, func(_ctx context.Context, attempt QueryAttempt) (*Iter, error) {
97101
ctx = _ctx
98-
iter := attempt.Query.execute(ctx, attempt.Conn)
102+
iter := attempt.Query.execute(ctx, conn)
99103
return iter, iter.err
100104
})
101105
if err != nil {

0 commit comments

Comments
 (0)