Repository navigation
Conversation
…set through Throttle Throttling takes its storage from the injector of the application, and an application with @throttling and no ThrottlingStorage fails on startup. The adapter gives handle_request the identity of its users: the Django adapter throttles by the Django user, by the client address otherwise. An API method with @throttling receives its Throttle, and throttle.reset() forgets what the scope counted for the identity the request was counted for. set_throttling_storage, set_throttling_identity_resolver and reset(request, scope) are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #348.
What
ThrottlingStoragethat the injector of the application binds:binder.bind(ThrottlingStorage, to=RedisThrottlingStorage(configuration)). An application with@throttlingand no storage fails increate_urlsinstead of on the first throttled request.handle_requestwith each request. The Django adapter throttles by the Django user, by the client address otherwise, as before; it no longer installs that into a process-global on its firstcreate_urls.@throttlingmay declarethrottle: winter.web.Throttle;throttle.reset()forgets what the scope has counted for the sender. It deletes the key the request was counted under, so it works even after the method has logged the user in, whichreset(request, scope)only did when called beforelogin().set_throttling_storage,get_throttling_storage,set_throttling_identity_resolver,get_throttling_identity,reset(request, scope).Why
The storage and the identity were process-globals, and the Django adapter replaced the identity silently on its first call. The consumer has never configured the identity: its rule is the Django user or the address, so that rule stays the adapter's and needs no code. A custom identity, such as the company of an API key for PO Tracing, can be added later through the injector without breaking this.
🤖 Generated with Claude Code