Module: ActiveRecordShards
- Defined in:
- lib/active_record_shards/sql_comments.rb,
lib/active_record_shards.rb,
lib/active_record_shards/model.rb,
lib/active_record_shards/tasks.rb,
lib/active_record_shards/migration.rb,
lib/active_record_shards/default_shard.rb,
lib/active_record_shards/shard_support.rb,
lib/active_record_shards/shard_selection.rb,
lib/active_record_shards/connection_switcher.rb,
lib/active_record_shards/configuration_parser.rb,
lib/active_record_shards/connection_switcher-5-1.rb,
lib/active_record_shards/connection_switcher-6-0.rb,
lib/active_record_shards/connection_switcher-6-1.rb,
lib/active_record_shards/connection_switcher-7-0.rb,
lib/active_record_shards/default_replica_patches.rb,
lib/active_record_shards/schema_dumper_extension.rb,
lib/active_record_shards/association_collection_connection_selection.rb
Overview
show which connection was picked to debug primary/replica slowness when both servers are the same
Defined Under Namespace
Modules: ActualMigrationExtension, AssociationCollectionConnectionSelection, ConfigurationParser, ConnectionSwitcher, DefaultReplicaPatches, DefaultShard, MigrationClassExtension, Model, SchemaDumperExtension, SqlComments, Tasks Classes: ShardSelection, ShardSupport
Class Attribute Summary collapse
-
.disable_replica_readonly_records ⇒ Object
Returns the value of attribute disable_replica_readonly_records.
Class Method Summary collapse
- .app_env ⇒ Object
-
.reset_app_env! ⇒ Object
Busts internal caches kept by active_record_shards, for things which are supposed to be the same for the life of the process.
Class Attribute Details
.disable_replica_readonly_records ⇒ Object
Returns the value of attribute disable_replica_readonly_records.
17 18 19 |
# File 'lib/active_record_shards.rb', line 17 def disable_replica_readonly_records @disable_replica_readonly_records end |
Class Method Details
.app_env ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_record_shards.rb', line 20 def self.app_env @app_env ||= begin env = Rails.env if defined?(Rails.env) env ||= RAILS_ENV if Object.const_defined?(:RAILS_ENV) env ||= ENV['RAILS_ENV'] env ||= APP_ENV if Object.const_defined?(:APP_ENV) env ||= ENV['APP_ENV'] env || 'development' end end |
.reset_app_env! ⇒ Object
Busts internal caches kept by active_record_shards, for things which are supposed to be the same for the life of the process. You shouldn’t need to call this unless you’re doing something truly evil like changing RAILS_ENV after boot
34 35 36 37 38 39 40 |
# File 'lib/active_record_shards.rb', line 34 def self.reset_app_env! @app_env = nil models = [ActiveRecord::Base] + ActiveRecord::Base.descendants models.each do |model| model.remove_instance_variable(:@_ars_model_is_sharded) if model.instance_variable_defined?(:@_ars_model_is_sharded) end end |