Replace a registry on registration instead of writing into it - #2976
Merged
Merged
Conversation
Danger ReportNo issues found. |
ericproulx
force-pushed
the
registry-frozen-copy-on-write
branch
3 times, most recently
from
September 20, 2026 20:46
a9cefbc to
69842b8
Compare
A registry is written when a formatter, parser, params builder, validator or versioner class is defined, and from then on it is only ever looked up -- on the request path, at that, once per response, per parsed body or per params build. Have register build the next Hash and freeze it, rather than writing into the one readers hold. Nothing can find a registry changed underneath it, and nothing can write to one without going through register. The spec-only deregister helper replaces the registry in turn. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ericproulx
force-pushed
the
registry-frozen-copy-on-write
branch
from
September 20, 2026 21:05
69842b8 to
87e20f6
Compare
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.
A registry is written when a formatter, parser, params builder, validator or versioner class is defined, and from then on it is only ever looked up — on the request path, at that: once per response by
Grape::Formatter, once per parsed body byGrape::Parser, once per params build byGrape::ParamsBuilder.Have
registerbuild the next Hash and freeze it, rather than writing into the one readers hold. Nothing can find a registry changed underneath it, and nothing can write to one without going throughregister.Notes:
spec/support/deregister.rb, the spec-only helper that undoes a registration, replaces the registry in turn. Nounregisteris added to the library.🤖 Generated with Claude Code