Sha256: 5233682d12044fb67b9030919285019a7aa073fb39f4b31106d0afed12aa10f1

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 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)
        klass = Class.new(PullMdmIdWorker) do
          sidekiq_options unique: :until_timeout, unique_expiration: model_class.global_registry_entity.mdm_timeout
        end
        const_set model_class.global_registry_entity.mdm_worker_class_name, 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

13 entries across 13 versions & 1 rubygems

Version Path
global-registry-bindings-0.3.1 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.3.0 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.2.0 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.9 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.8 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.7 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.6 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.5 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.4 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.3 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.2 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.1 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
global-registry-bindings-0.1.0 lib/global_registry_bindings/workers/pull_mdm_id_worker.rb