You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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))
}
The text was updated successfully, but these errors were encountered:
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 theQueryObserver
andBatchObserver
:The text was updated successfully, but these errors were encountered: