class Sidekiq::CurrentAttributes::Load
Public Class Methods
Source
# File lib/sidekiq/middleware/current_attributes.rb, line 49 def initialize(cattrs) @cattrs = cattrs end
Public Instance Methods
Source
# File lib/sidekiq/middleware/current_attributes.rb, line 53 def call(_, job, _, &block) klass_attrs = {} @cattrs.each do |(key, strklass)| next unless job.has_key?(key) klass_attrs[strklass.constantize] = Serializer.deserialize(job[key]).to_h end wrap(klass_attrs.to_a, &block) end
Private Instance Methods
Source
# File lib/sidekiq/middleware/current_attributes.rb, line 67 def wrap(klass_attrs, &block) klass, attrs = klass_attrs.shift return block.call unless klass retried = false begin set_succeeded = false klass.set(attrs) do set_succeeded = true wrap(klass_attrs, &block) end rescue NoMethodError # Don't retry if the no method error didn't come from current attributes raise if retried || set_succeeded # It is possible that the `CurrentAttributes` definition # was changed before the job started processing. attrs = attrs.select { |attr| klass.respond_to?(attr) } retried = true retry end end