闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
599 B

  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 = enabled ? :sidekiq : :bypass
  14. Chewy.request_strategy = enabled ? :sidekiq : :bypass
  15. module Chewy
  16. class << self
  17. def enabled?
  18. settings[:enabled]
  19. end
  20. end
  21. end