module ActiveJob::Locking::Base
Public Instance Methods
adapter()
click to toggle source
# File lib/activejob/locking/base.rb, line 31 def adapter @adapter ||= begin # Make sure arguments are deserialized so calling lock key is safe begin deserialize_arguments_if_needed rescue => exception rescue_with_handler(exception) || raise end # Merge local and global options merged_options = ActiveJob::Locking.options.dup.merge(self.class.lock_options) # Get the key base_key = self.lock_key(*self.arguments) key = "activejoblocking:#{base_key}" # Remember the lock might be acquired in one process and released in another merged_options.adapter.new(key, merged_options) end @adapter end
deserialize(job_data)
click to toggle source
Calls superclass method
# File lib/activejob/locking/base.rb, line 22 def deserialize(job_data) super self.adapter.lock_token = job_data['lock_token'] end
lock_key(*args)
click to toggle source
# File lib/activejob/locking/base.rb, line 27 def lock_key(*args) [self.class.name, serialize_arguments(self.arguments)].join('/') end
serialize()
click to toggle source
We need to serialize the lock token that some gems create because it could be released in a different process
Calls superclass method
# File lib/activejob/locking/base.rb, line 16 def serialize result = super result['lock_token'] = self.adapter.lock_token result end