diff options
Diffstat (limited to 'config/initializers/chewy.rb')
-rw-r--r-- | config/initializers/chewy.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/config/initializers/chewy.rb b/config/initializers/chewy.rb new file mode 100644 index 000000000..d5347f2bf --- /dev/null +++ b/config/initializers/chewy.rb @@ -0,0 +1,24 @@ +enabled = ENV['ES_ENABLED'] == 'true' +host = ENV.fetch('ES_HOST') { 'localhost' } +port = ENV.fetch('ES_PORT') { 9200 } +fallback_prefix = ENV.fetch('REDIS_NAMESPACE') { nil } +prefix = ENV.fetch('ES_PREFIX') { fallback_prefix } + +Chewy.settings = { + host: "#{host}:#{port}", + prefix: prefix, + enabled: enabled, + journal: false, + sidekiq: { queue: 'pull' }, +} + +Chewy.root_strategy = enabled ? :sidekiq : :bypass +Chewy.request_strategy = enabled ? :sidekiq : :bypass + +module Chewy + class << self + def enabled? + settings[:enabled] + end + end +end |