martin-sucha commented on code in PR #1820:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1820#discussion_r1760656947


##########
query_executor.go:
##########
@@ -48,16 +48,60 @@ type ExecutableQuery interface {
 }
 
 type queryExecutor struct {
-       pool   *policyConnPool
-       policy HostSelectionPolicy
+       pool        *policyConnPool
+       policy      HostSelectionPolicy
+       interceptor QueryAttemptInterceptor
+}
+
+type QueryAttempt struct {
+       // The query to execute, either a *gocql.Query or *gocql.Batch.
+       Query ExecutableQuery
+       // The connection used to execute the query.
+       Conn *Conn
+       // The host that will receive the query.
+       Host *HostInfo
+       // The number of previous query attempts. 0 for the initial attempt, 1 
for the first retry, etc.
+       Attempts int
+}
+
+// QueryAttemptHandler is a function that attempts query execution.
+type QueryAttemptHandler = func(context.Context, QueryAttempt) *Iter
+
+// QueryAttemptInterceptor is the interface implemented by query interceptors 
/ middleware.
+//
+// Interceptors are well-suited to logic that is not specific to a single 
query or batch.
+type QueryAttemptInterceptor interface {
+       // Intercept is invoked once immediately before a query execution 
attempt, including retry attempts and
+       // speculative execution attempts.
+
+       // The interceptor is responsible for calling the `handler` function 
and returning the handler result. Failure to
+       // call the handler will panic. If the interceptor wants to halt query 
execution and prevent retries, it should
+       // return an error.

Review Comment:
   **nitpick**: The function does not have an `error` return value. Should we 
add an error return value or should we reference  `NewIterWithErr` instead?
   
   **question**: How does returning an error prevent a retry?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to