Draft
Conversation
ensure #load_class performs all accesses of @registered_middleware in a single mutex call
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.
This extracts the
Faraday::MiddlewareRegistrymodule functionality into aFaraday::ClassRegistryclass. This allows us to make some better assumptions about how the class registry's internal vars are loaded.TODO:
ClassRegistryI also made a few small changes that may bite us later:
#load_middleware. It's the same as#lookup_middleware, except#lookup_middlewareraises if it doesn't return anything. When deciding betweenClassRegistry#lookupand#load, I went with#lookupsince#loadis an existing ruby method.faraday/lib/faraday/middleware_registry.rb
Lines 207 to 214 in 1c5672a
#middleware_mutexand#fetch_middleware. Those should've been private originally. They're not used elsewhere in Faraday, but may be in use in an external lib or app. Pretty low chance though...faraday/lib/faraday/middleware_registry.rb
Lines 216 to 222 in 1c5672a
#register_middlewarenow complains if you try to change theautoload_path_after the ClassRegistry has been setup`. So, something like:faraday/lib/faraday/middleware_registry.rb
Lines 173 to 175 in 1c5672a