Sha256: a18c362061fe06f6c07df103c4a4ed37fa9bbb367125a485792378a97b1444c7
Contents?: true
Size: 1.09 KB
Versions: 10
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true require 'sidekiq' require 'sidekiq-unique-jobs' module GlobalRegistry #:nodoc: module Bindings #:nodoc: class Worker include Sidekiq::Worker attr_accessor :model delegate :global_registry_entity, to: :model delegate :global_registry_relationship, to: :model def initialize(model = nil) self.model = model end def perform(model_class, id) klass = model_class.is_a?(String) ? model_class.constantize : model_class self.model = klass.find(id) end def self.perform_async(*args) # Set global sidekiq_options worker = set(GlobalRegistry::Bindings.sidekiq_options) if worker == self # sidekiq 4.x super(*args) else # sidekiq 5.x worker.perform_async(*args) end rescue Redis::BaseError => e case GlobalRegistry::Bindings.redis_error_action when :raise raise when :log ::Rollbar.error(e) if Module.const_defined? :Rollbar when :ignore return end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems