@@ -172,6 +172,144 @@ module Tasks
172
172
singleton_class . attr_accessor :legacy_connection_handling
173
173
self . legacy_connection_handling = true
174
174
175
+ ##
176
+ # :singleton-method:
177
+ # Determines whether to use Time.utc (using :utc) or Time.local (using :local) when pulling
178
+ # dates and times from the database. This is set to :utc by default.
179
+ singleton_class . attr_accessor :default_timezone
180
+ self . default_timezone = :utc
181
+
182
+ singleton_class . attr_accessor :writing_role
183
+ self . writing_role = :writing
184
+
185
+ singleton_class . attr_accessor :reading_role
186
+ self . reading_role = :reading
187
+
188
+ # Sets the async_query_executor for an application. By default the thread pool executor
189
+ # set to +nil+ which will not run queries in the background. Applications must configure
190
+ # a thread pool executor to use this feature. Options are:
191
+ #
192
+ # * nil - Does not initialize a thread pool executor. Any async calls will be
193
+ # run in the foreground.
194
+ # * :global_thread_pool - Initializes a single +Concurrent::ThreadPoolExecutor+
195
+ # that uses the +async_query_concurrency+ for the +max_threads+ value.
196
+ # * :multi_thread_pool - Initializes a +Concurrent::ThreadPoolExecutor+ for each
197
+ # database connection. The initializer values are defined in the configuration hash.
198
+ singleton_class . attr_accessor :async_query_executor
199
+ self . async_query_executor = nil
200
+
201
+ def self . global_thread_pool_async_query_executor # :nodoc:
202
+ concurrency = global_executor_concurrency || 4
203
+ @global_thread_pool_async_query_executor ||= Concurrent ::ThreadPoolExecutor . new (
204
+ min_threads : 0 ,
205
+ max_threads : concurrency ,
206
+ max_queue : concurrency * 4 ,
207
+ fallback_policy : :caller_runs
208
+ )
209
+ end
210
+
211
+ # Set the +global_executor_concurrency+. This configuration value can only be used
212
+ # with the global thread pool async query executor.
213
+ def self . global_executor_concurrency = ( global_executor_concurrency )
214
+ if self . async_query_executor . nil? || self . async_query_executor == :multi_thread_pool
215
+ raise ArgumentError , "`global_executor_concurrency` cannot be set when using the executor is nil or set to multi_thead_pool. For multiple thread pools, please set the concurrency in your database configuration."
216
+ end
217
+
218
+ @global_executor_concurrency = global_executor_concurrency
219
+ end
220
+
221
+ def self . global_executor_concurrency # :nodoc:
222
+ @global_executor_concurrency ||= nil
223
+ end
224
+
225
+ ##
226
+ # :singleton-method:
227
+ #
228
+ # Specifies if the methods calling database queries should be logged below
229
+ # their relevant queries. Defaults to false.
230
+ singleton_class . attr_accessor :verbose_query_logs
231
+ self . verbose_query_logs = false
232
+
233
+ ##
234
+ # :singleton-method:
235
+ #
236
+ # Specifies the names of the queues used by background jobs.
237
+ singleton_class . attr_accessor :queues
238
+ self . queues = { }
239
+
240
+ singleton_class . attr_accessor :maintain_test_schema
241
+ self . maintain_test_schema = nil
242
+
243
+ ##
244
+ # :singleton-method:
245
+ # Specify a threshold for the size of query result sets. If the number of
246
+ # records in the set exceeds the threshold, a warning is logged. This can
247
+ # be used to identify queries which load thousands of records and
248
+ # potentially cause memory bloat.
249
+ singleton_class . attr_accessor :warn_on_records_fetched_greater_than
250
+ self . warn_on_records_fetched_greater_than = false
251
+
252
+ singleton_class . attr_accessor :application_record_class
253
+ self . application_record_class = nil
254
+
255
+ ##
256
+ # :singleton-method:
257
+ # Set the application to log or raise when an association violates strict loading.
258
+ # Defaults to :raise.
259
+ singleton_class . attr_accessor :action_on_strict_loading_violation
260
+ self . action_on_strict_loading_violation = :raise
261
+
262
+ ##
263
+ # :singleton-method:
264
+ # Specifies the format to use when dumping the database schema with Rails'
265
+ # Rakefile. If :sql, the schema is dumped as (potentially database-
266
+ # specific) SQL statements. If :ruby, the schema is dumped as an
267
+ # ActiveRecord::Schema file which can be loaded into any database that
268
+ # supports migrations. Use :ruby if you want to have different database
269
+ # adapters for, e.g., your development and test environments.
270
+ singleton_class . attr_accessor :schema_format
271
+ self . schema_format = :ruby
272
+
273
+ ##
274
+ # :singleton-method:
275
+ # Specifies if an error should be raised if the query has an order being
276
+ # ignored when doing batch queries. Useful in applications where the
277
+ # scope being ignored is error-worthy, rather than a warning.
278
+ singleton_class . attr_accessor :error_on_ignored_order
279
+ self . error_on_ignored_order = false
280
+
281
+ ##
282
+ # :singleton-method:
283
+ # Specify whether or not to use timestamps for migration versions
284
+ singleton_class . attr_accessor :timestamped_migrations
285
+ self . timestamped_migrations = true
286
+
287
+ ##
288
+ # :singleton-method:
289
+ # Specify whether schema dump should happen at the end of the
290
+ # bin/rails db:migrate command. This is true by default, which is useful for the
291
+ # development environment. This should ideally be false in the production
292
+ # environment where dumping schema is rarely needed.
293
+ singleton_class . attr_accessor :dump_schema_after_migration
294
+ self . dump_schema_after_migration = true
295
+
296
+ ##
297
+ # :singleton-method:
298
+ # Specifies which database schemas to dump when calling db:schema:dump.
299
+ # If the value is :schema_search_path (the default), any schemas listed in
300
+ # schema_search_path are dumped. Use :all to dump all schemas regardless
301
+ # of schema_search_path, or a string of comma separated schemas for a
302
+ # custom list.
303
+ singleton_class . attr_accessor :dump_schemas
304
+ self . dump_schemas = :schema_search_path
305
+
306
+ ##
307
+ # :singleton-method:
308
+ # Show a warning when Rails couldn't parse your database.yml
309
+ # for multiple databases.
310
+ singleton_class . attr_accessor :suppress_multiple_database_warning
311
+ self . suppress_multiple_database_warning = false
312
+
175
313
def self . eager_load!
176
314
super
177
315
ActiveRecord ::Locking . eager_load!
0 commit comments