chewy.rb 634 B

12345678910111213141516171819202122232425
  1. enabled = ENV['ES_ENABLED'] == 'true'
  2. host = ENV.fetch('ES_HOST') { 'localhost' }
  3. port = ENV.fetch('ES_PORT') { 9200 }
  4. fallback_prefix = ENV.fetch('REDIS_NAMESPACE') { nil }
  5. prefix = ENV.fetch('ES_PREFIX') { fallback_prefix }
  6. Chewy.settings = {
  7. host: "#{host}:#{port}",
  8. prefix: prefix,
  9. enabled: enabled,
  10. journal: false,
  11. sidekiq: { queue: 'pull' },
  12. }
  13. Chewy.root_strategy = :custom_sidekiq
  14. Chewy.request_strategy = :custom_sidekiq
  15. Chewy.use_after_commit_callbacks = false
  16. module Chewy
  17. class << self
  18. def enabled?
  19. settings[:enabled]
  20. end
  21. end
  22. end