Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary or incorrect calls to connection_handler #45592

Conversation

eileencodes
Copy link
Member

In an effort to find all the internal callers of connection_handler I
decided to remove any uses that are either:

  1. Unnecessary - we can call what we need on Base or elsewhere without
    going through the handler
  2. Incorrect - there's a better way call the same thing. For example
    avoiding calling the ivar, and instead calling send on an existing
    method.

Doing this will inform us what cases the connection handler is required
and how we can expand Base to provide everything an application or gem
could need without going through the handler. Reducing calls makes it
easier to replace or refactor in the future.

In an effort to find all the internal callers of `connection_handler` I
decided to remove any uses that are either:

1) Unnecessary - we can call what we need on Base or elsewhere without
going through the handler
2) Incorrect - there's a better way call the same thing. For exmaple
avoiding calling the ivar, and instead calling `send` on an existing
method.

Doing this will inform us what cases the connection handler is required
and how we can expand Base to provide everything an application or gem
could need without going through the handler. Reducing calls makes it
easier to replace or refactor in the future.
@@ -174,8 +174,6 @@ def retrieve_connection(connection_name, role: ActiveRecord::Base.current_role,
unless pool
if shard != ActiveRecord::Base.default_shard
message = "No connection pool for '#{connection_name}' found for the '#{shard}' shard."
elsif ActiveRecord::Base.connection_handler != ActiveRecord::Base.default_connection_handler
message = "No connection pool for '#{connection_name}' found for the '#{ActiveRecord::Base.current_role}' role."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer use multiple handlers to control the pools so we don't need this error anymore.

@eileencodes eileencodes merged commit 812bae8 into rails:main Jul 13, 2022
@eileencodes eileencodes deleted the remove-unnecessary-connection_handler-calls branch July 13, 2022 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant