Module: SidekiqUniqueJobs::Scripts
- Extended by:
- SingleForwardable
- Includes:
- Overrides
- Defined in:
- lib/sidekiq_unique_jobs/scripts.rb,
lib/sidekiq_unique_jobs/testing.rb,
lib/sidekiq_unique_jobs/scripts/acquire_lock.rb,
lib/sidekiq_unique_jobs/scripts/release_lock.rb
Defined Under Namespace
Modules: Overrides Classes: AcquireLock, ReleaseLock
Class Method Summary collapse
-
.call(file_name, redis_pool, options = {}) ⇒ Object
rubocop:disable MethodLength.
- .script_path(file_name) ⇒ Object
- .script_source(file_name) ⇒ Object
Methods included from Overrides
Class Method Details
.call(file_name, redis_pool, options = {}) ⇒ Object
rubocop:disable MethodLength
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sidekiq_unique_jobs/scripts.rb', line 25 def call(file_name, redis_pool, = {}) # rubocop:disable MethodLength connection(redis_pool) do |redis| if SCRIPT_SHAS[file_name].nil? SCRIPT_SHAS[file_name] = redis.script(:load, script_source(file_name)) end redis.evalsha(SCRIPT_SHAS[file_name], ) end rescue Redis::CommandError => ex if ex. == 'NOSCRIPT No matching script. Please use EVAL.' SCRIPT_SHAS.delete(file_name) call(file_name, redis_pool, ) raise else raise ScriptError, "#{file_name}.lua\n\n#{ex.message}\n\n#{script_source(file_name)}" \ "#{ex.backtrace.join("\n")}" end end |
.script_path(file_name) ⇒ Object
48 49 50 |
# File 'lib/sidekiq_unique_jobs/scripts.rb', line 48 def script_path(file_name) LUA_PATHNAME.join("#{file_name}.lua") end |
.script_source(file_name) ⇒ Object
44 45 46 |
# File 'lib/sidekiq_unique_jobs/scripts.rb', line 44 def script_source(file_name) script_path(file_name).read end |