Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASSGO-39 Add query attempt interceptor #1786

Open
martin-sucha opened this issue Jul 29, 2024 · 0 comments
Open

CASSGO-39 Add query attempt interceptor #1786

martin-sucha opened this issue Jul 29, 2024 · 0 comments

Comments

@martin-sucha
Copy link
Contributor

There are use-cases for wrapping the executions of individual query attempts.

We currently have QueryObserver and BatchObserver that allow observing the query attempts, but don't allow modification of behavior.

One use case that requires modification of behavior is a request rate limiter (#1756) or a semaphore to limit request concurrency.

It seems that instead of adding an individual interface for each use case, a single interceptor-like interface could serve all of them.

The following QueryAttemptInterceptor could be used to implement the rate limiter, however we will need to make changes the interface to be able to replace the QueryObserver and BatchObserver:

type QueryAttemptInterceptor interface {
    // AttemptQuery executes the query on the given connection.
    // The attempt function does the actual work, the AttempQuery implementation is free to execute code
    // before/after the call to the attempt function or skip the call altogether.
    // If error is nil, the returned *Iter must be non-nil.
    AttemptQuery(ctx context.Context, query ExecutableQuery, conn *Conn, attempt func(ctx context, query ExecutableQuery, conn *Conn) *Iter) (*Iter, error))
}
@joao-r-reis joao-r-reis changed the title Add query attempt interceptor CASSGO-39 Add query attempt interceptor Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant