Skip to content

Commit

Permalink
Move redis into its own config
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadel committed May 25, 2023
1 parent fc85f2c commit 3a48706
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
8 changes: 5 additions & 3 deletions config/initializers/mini_profiler.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

redis_config = YAML.safe_load(ERB.new(File.read(Rails.root.join("config", "redis.yml"))).result, aliases: true)[Rails.env].with_indifferent_access

Rack::MiniProfiler.config.storage_options = {
host: Orangelight.config[:redis][:host],
port: Orangelight.config[:redis][:port],
db: Orangelight.config[:redis][:db]
host: redis_config[:host],
port: redis_config[:port],
db: redis_config[:db]
}
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
# Named 01_orangelight_config.rb to force it to load before the mini_profiler.rb, which depends on it
module Orangelight
def config
@config ||= config_yaml.with_indifferent_access
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/sneakers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'sneakers'
require 'sneakers/handlers/maxretry'
require_relative '01_orangelight_config'
require_relative 'orangelight_config'
Sneakers.configure(
amqp: Orangelight.config['events']['server'],
exchange: Orangelight.config['events']['exchange'],
Expand Down
34 changes: 34 additions & 0 deletions config/redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
defaults: &defaults
host: 'localhost'
port: '6379'
db: 'orangelight_default'
development:
<<: *defaults
host: <%= ENV['lando_orangelight_redis_conn_host'] %>
port: <%= ENV['lando_orangelight_redis_conn_port'] %>
db: 'orangelight_dev'
test:
<<: *defaults
host: <%= ENV['lando_orangelight_redis_conn_host'] %>
port: <%= ENV['lando_orangelight_redis_conn_port'] %>
db: 'orangelight_test'
production:
<<: *defaults
host: <%= ENV['OL_REDIS_HOST'] %>
port: <%= ENV['OL_REDIS_PORT'] || '6379' %>
db: 'orangelight_prod'
staging:
<<: *defaults
host: <%= ENV['OL_REDIS_HOST'] %>
port: <%= ENV['OL_REDIS_PORT'] || '6379' %>
db: 'orangelight_staging'
alma_qa:
<<: *defaults
host: <%= ENV['OL_REDIS_HOST'] %>
port: <%= ENV['OL_REDIS_PORT'] || '6379' %>
db: 'orangelight_qa'
qa:
<<: *defaults
host: <%= ENV['OL_REDIS_HOST'] %>
port: <%= ENV['OL_REDIS_PORT'] || '6379' %>
db: 'orangelight_qa'

0 comments on commit 3a48706

Please sign in to comment.