lib/octopus.rb in ar-octopus-0.8.4 vs lib/octopus.rb in ar-octopus-0.8.5
- old
+ new
@@ -62,10 +62,24 @@
def self.environments
@environments ||= config['environments'] || ['production']
end
+ def self.robust_environments=(environments)
+ @robust_environments = environments.map(&:to_s)
+ end
+
+ # Environments in which to swallow failures from a single shard
+ # when iterating through all.
+ def self.robust_environments
+ @robust_environments ||= config['robust_environments'] || ['production']
+ end
+
+ def self.robust_environment?
+ robust_environments.include? rails_env
+ end
+
def self.rails3?
ActiveRecord::VERSION::MAJOR <= 3
end
def self.rails4?
@@ -76,9 +90,19 @@
rails4? && ActiveRecord::VERSION::MINOR >= 1
end
def self.rails?
defined?(Rails)
+ end
+
+ attr_writer :logger
+
+ def self.logger
+ if defined?(Rails)
+ @logger ||= Rails.logger
+ else
+ @logger ||= Logger.new($stderr)
+ end
end
def self.shards=(shards)
config[rails_env] = HashWithIndifferentAccess.new(shards)
ActiveRecord::Base.connection.initialize_shards(@config)