Sha256: 46b4c18fd379836e93ddc2cdc6062e60040d3eb86e410aa0a0e6af4a05f973c7

Contents?: true

Size: 455 Bytes

Versions: 1

Compression:

Stored size: 455 Bytes

Contents

require "sucker_punch"

class ActiveSearch::Algolia::Worker
  include SuckerPunch::Job
  
  def perform(msg)
    begin
      case msg[:task]
      when :reindex
        ::ActiveSearch::Algolia::Client.new.save(msg[:id], msg[:doc])
      when :deindex
        ::ActiveSearch::Algolia::Client.new.delete(msg[:id])
      end
    rescue Exception => e
      perform(msg.merge!(retries: msg[:retries].to_i + 1)) unless msg[:retries].to_i >= 3
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activesearch-0.1.3 lib/activesearch/algolia/worker.rb