Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis: allow full configurability #255

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ storage_directory: storage
legacy_purge_days: 2

# Sidekiq configuration settings - which redis to use and namespace
redis_url: <%= ENV.fetch('REDIS_URL', 'redis://localhost:6379/4') %>
redis_namespace: colore
redis:
:url: <%= ENV.fetch('REDIS_URL', 'redis://localhost:6379/4') %>
:namespace: colore

# Conversion processes log
conversion_log: log/converter.log
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
require 'config'

Sidekiq.configure_server do |config|
config.redis = { url: Colore::C_.redis_url, namespace: Colore::C_.redis_namespace }
config.redis = Colore::C_.redis
end

Sidekiq.configure_client do |config|
config.redis = { url: Colore::C_.redis_url, namespace: Colore::C_.redis_namespace }
config.redis = Colore::C_.redis
end
9 changes: 3 additions & 6 deletions lib/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ class C_
attr_accessor :legacy_url_base
# Number of days to keep legacy files before purging
attr_accessor :legacy_purge_days
# Redis connection URL (used by sidekiq)
attr_accessor :redis_url
# Redis namespace (used by sidekiq)
attr_accessor :redis_namespace
# Redis configuration (used by sidekiq)
attr_accessor :redis
# Path to the Heathen conversion log
attr_accessor :conversion_log
# Path to the Error log
Expand Down Expand Up @@ -56,8 +54,7 @@ def self.config
c.storage_directory = yaml['storage_directory']
c.legacy_url_base = yaml['legacy_url_base']
c.legacy_purge_days = yaml['legacy_purge_days'].to_i
c.redis_url = yaml['redis_url']
c.redis_namespace = yaml['redis_namespace']
c.redis = yaml['redis']
c.conversion_log = yaml['conversion_log']
c.error_log = yaml['error_log']

Expand Down
5 changes: 3 additions & 2 deletions spec/fixtures/app.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
storage_directory: foo
redis_url: bar
redis_namespace: <%= ENV.fetch('TEST_REDIS_NAMESPACE', 'foobar') %>
redis:
:url: bar
:namespace: <%= ENV.fetch('TEST_REDIS_NAMESPACE', 'foobar') %>
2 changes: 1 addition & 1 deletion spec/lib/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

it 'reads from environment variables' do
expect(ENV).to receive(:fetch).with('TEST_REDIS_NAMESPACE', 'foobar').and_return('custom')
expect(described_class.config.redis_namespace).to eq 'custom'
expect(described_class.config.redis[:namespace]).to eq 'custom'
end
end

Expand Down