Module: PgFailover

Defined in:
lib/pg_failover.rb,
lib/pg_failover/config.rb,
lib/pg_failover/throttle.rb,
lib/pg_failover/sequel_adapter.rb,
lib/pg_failover/connection_validator.rb,
lib/pg_failover/active_record_adapter.rb

Defined Under Namespace

Modules: SequelAdapter Classes: ActiveRecordAdapter, Config, ConnectionValidator, Throttle

Class Method Summary collapse

Class Method Details

.configurationObject



33
34
35
# File 'lib/pg_failover.rb', line 33

def configuration
  @configuration ||= Config.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pg_failover.rb', line 11

def configure
  yield configuration if block_given?

  if configuration.enabled?
    if configuration.throttle_enabled?
      configuration.logger.info("Enabled PgFailover policy (one check per #{configuration.throttle_interval} seconds per connection on checkout)")
    else
      configuration.logger.info('Enabled PgFailover policy (one check for every checkout from the connection pool)')
    end

    SequelAdapter.enable if defined?(::Sequel)
    ActiveRecordAdapter.enable if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)

  else
    configuration.logger.warn 'Disabled PgFailover policy'
  end
end

.connection_validatorObject



29
30
31
# File 'lib/pg_failover.rb', line 29

def connection_validator
  @connection_validator ||= ConnectionValidator.new(configuration)
end