@@ -88,14 +88,10 @@ def connection_pool_names # :nodoc:
88
88
connection_name_to_pool_manager . keys
89
89
end
90
90
91
- # Returns the pools for a connection handler and given role. If +:all+ is passed,
91
+ # Returns the pools for a connection handler and given role. If +:all+ is passed,
92
92
# all pools belonging to the connection handler will be returned.
93
93
def connection_pool_list ( role = nil )
94
- if role . nil?
95
- deprecation_for_pool_handling ( __method__ )
96
- role = ActiveRecord ::Base . current_role
97
- connection_name_to_pool_manager . values . flat_map { |m | m . pool_configs ( role ) . map ( &:pool ) }
98
- elsif role == :all
94
+ if role . nil? || role == :all
99
95
connection_name_to_pool_manager . values . flat_map { |m | m . pool_configs . map ( &:pool ) }
100
96
else
101
97
connection_name_to_pool_manager . values . flat_map { |m | m . pool_configs ( role ) . map ( &:pool ) }
@@ -157,23 +153,13 @@ def establish_connection(config, owner_name: Base, role: Base.current_role, shar
157
153
# Returns true if there are any active connections among the connection
158
154
# pools that the ConnectionHandler is managing.
159
155
def active_connections? ( role = nil )
160
- if role . nil?
161
- deprecation_for_pool_handling ( __method__ )
162
- role = ActiveRecord ::Base . current_role
163
- end
164
-
165
156
each_connection_pool ( role ) . any? ( &:active_connection? )
166
157
end
167
158
168
159
# Returns any connections in use by the current thread back to the pool,
169
160
# and also returns connections to the pool cached by threads that are no
170
161
# longer alive.
171
162
def clear_active_connections! ( role = nil )
172
- if role . nil?
173
- deprecation_for_pool_handling ( __method__ )
174
- role = ActiveRecord ::Base . current_role
175
- end
176
-
177
163
each_connection_pool ( role ) . each do |pool |
178
164
pool . release_connection
179
165
pool . disable_query_cache!
@@ -184,32 +170,17 @@ def clear_active_connections!(role = nil)
184
170
#
185
171
# See ConnectionPool#clear_reloadable_connections! for details.
186
172
def clear_reloadable_connections! ( role = nil )
187
- if role . nil?
188
- deprecation_for_pool_handling ( __method__ )
189
- role = ActiveRecord ::Base . current_role
190
- end
191
-
192
173
each_connection_pool ( role ) . each ( &:clear_reloadable_connections! )
193
174
end
194
175
195
176
def clear_all_connections! ( role = nil )
196
- if role . nil?
197
- deprecation_for_pool_handling ( __method__ )
198
- role = ActiveRecord ::Base . current_role
199
- end
200
-
201
177
each_connection_pool ( role ) . each ( &:disconnect! )
202
178
end
203
179
204
180
# Disconnects all currently idle connections.
205
181
#
206
182
# See ConnectionPool#flush! for details.
207
183
def flush_idle_connections! ( role = nil )
208
- if role . nil?
209
- deprecation_for_pool_handling ( __method__ )
210
- role = ActiveRecord ::Base . current_role
211
- end
212
-
213
184
each_connection_pool ( role ) . each ( &:flush! )
214
185
end
215
186
@@ -273,23 +244,6 @@ def pool_managers
273
244
connection_name_to_pool_manager . values
274
245
end
275
246
276
- def deprecation_for_pool_handling ( method )
277
- roles = [ ]
278
- pool_managers . each do |pool_manager |
279
- roles << pool_manager . role_names
280
- end
281
-
282
- if roles . flatten . uniq . count > 1
283
- ActiveRecord . deprecator . warn ( <<-MSG . squish )
284
- `#{ method } ` currently only applies to connection pools in the current
285
- role (`#{ ActiveRecord ::Base . current_role } `). In Rails 7.2, this method
286
- will apply to all known pools, regardless of role. To affect only those
287
- connections belonging to a specific role, pass the role name as an
288
- argument. To switch to the new behavior, pass `:all` as the role name.
289
- MSG
290
- end
291
- end
292
-
293
247
def disconnect_pool_from_pool_manager ( pool_manager , role , shard )
294
248
pool_config = pool_manager . remove_pool_config ( role , shard )
295
249
0 commit comments