request/ratelimit: Add context value check and fix bug (#2073)

* Add WithNoDelayPermitted and fix bug on cancel all

* rm reservations as it is only for last reservation when cancelling and needed to take into account of the actual offset delay for correct returning of tokens, update tests

* export error

* misc fix

* more misc fix

* Add concurrent protection, cancel in reverse and add tests

* lint: fix

* Update exchanges/request/limit.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/request/limit.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/request/limit.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/request/limit.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* gk: nits doo

* linter: fix

* boss king: nits

* crank: nits

* crank: test patch which was cooked and had to be done manually

* Update exchanges/request/limit.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* gk: nits

* linter: fix

* thrasher: nits

* use error collector in tests

* nolint: direction

* gk: fixup!

* my life has elapsed

* thrasher-: Because of synctest, we can now be deterministic with values. This rids a lot of the redundant wait calls which served no purpose

* thrasher-: patched

---------

Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
Co-authored-by: shazbert <shazbert@DESKTOP-3QKKR6J.localdomain>
This commit is contained in:
Ryan O'Hara-Reid
2025-11-27 11:10:11 +11:00
committed by GitHub
parent 2943a7f800
commit 719e6bebfe
4 changed files with 348 additions and 114 deletions

View File

@@ -204,7 +204,7 @@ func (c *connection) writeToConn(ctx context.Context, epl request.EndpointLimit,
}
if rl != nil {
if err := request.RateLimit(ctx, rl); err != nil {
if err := rl.RateLimit(ctx); err != nil {
return fmt.Errorf("%s websocket connection: rate limit error: %w", c.ExchangeName, err)
}
}