Sha256: bffcfec72f2981a775195ece7140c6ce9b7e881386b18e84e182f294336a6e91

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require 'global_registry_bindings/entity/mdm_methods'

module GlobalRegistry #:nodoc:
  module Bindings #:nodoc:
    module Workers #:nodoc:
      def self.mdm_worker_class(model_class)
        worker_class_name = model_class.global_registry_entity.mdm_worker_class_name
        return const_get worker_class_name if const_defined? worker_class_name

        klass = Class.new(PullMdmIdWorker) do
          sidekiq_options unique: :until_timeout, unique_expiration: model_class.global_registry_entity.mdm_timeout
        end

        const_set worker_class_name, klass
        ActiveSupport::Dependencies.mark_for_unload(klass)

        klass
      end

      class PullMdmIdWorker < ::GlobalRegistry::Bindings::Worker
        include GlobalRegistry::Bindings::Entity::MdmMethods

        def perform(model_class, id)
          super model_class, id
          pull_mdm_id_from_global_registry
        rescue ActiveRecord::RecordNotFound
          # If the record was deleted after the job was created, swallow it
          return
        rescue RestClient::ResourceNotFound
          Rails.logger.info "GR entity for #{self.class.name} #{id} does not exist; will _not_ retry"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
global-registry-bindings-0.6.2 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.6.1 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.6.0 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.5.0 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.4.0 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.3.3 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.3.2 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb