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.

30 lines
685 B

  1. # frozen_string_literal: true
  2. module Chewy
  3. class Strategy
  4. class CustomSidekiq < Base
  5. class Worker
  6. include ::Sidekiq::Worker
  7. sidekiq_options queue: 'pull'
  8. def perform(type, ids, options = {})
  9. options[:refresh] = !Chewy.disable_refresh_async if Chewy.disable_refresh_async
  10. type.constantize.import!(ids, options)
  11. end
  12. end
  13. def update(type, objects, _options = {})
  14. return unless Chewy.enabled?
  15. ids = type.root.id ? Array.wrap(objects) : type.adapter.identify(objects)
  16. return if ids.empty?
  17. Worker.perform_async(type.name, ids)
  18. end
  19. def leave; end
  20. end
  21. end
  22. end