Class: Readyset::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/readyset/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
11
# File 'lib/readyset/configuration.rb', line 8

def initialize
  @migration_path = File.join(Rails.root, 'db/readyset_caches.rb')
  @shard = :readyset
end

Instance Attribute Details

#migration_pathObject

Returns the value of attribute migration_path.



6
7
8
# File 'lib/readyset/configuration.rb', line 6

def migration_path
  @migration_path
end

#shardObject

Returns the value of attribute shard.



6
7
8
# File 'lib/readyset/configuration.rb', line 6

def shard
  @shard
end

Instance Method Details

#failoverObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/readyset/configuration.rb', line 13

def failover
  if @failover
    @failover
  else
    inner = ActiveSupport::OrderedOptions.new
    inner.enabled = false
    inner.healthcheck_interval = 5.seconds
    inner.error_window_period = 1.minute
    inner.error_window_size = 10
    @failover = inner
  end
end

#hostnameObject



26
27
28
# File 'lib/readyset/configuration.rb', line 26

def hostname
  ActiveRecord::Base.configurations.configs_for(name: shard.to_s).configuration_hash[:host]
end