From 70f44f24b737aecff384bcac08433fdcc79f4024 Mon Sep 17 00:00:00 2001 From: mhenrixon Date: Wed, 24 Jan 2024 10:57:46 +0200 Subject: [PATCH] chore: update docs --- doc/Array.html | 8 +- doc/Hash.html | 8 +- doc/Sidekiq.html | 40 +- doc/Sidekiq/Job.html | 8 +- doc/Sidekiq/Job/UniqueExtension.html | 8 +- doc/Sidekiq/JobRecord.html | 8 +- doc/Sidekiq/JobRecord/UniqueExtension.html | 8 +- doc/Sidekiq/JobSet.html | 8 +- doc/Sidekiq/JobSet/UniqueExtension.html | 8 +- doc/Sidekiq/Queue.html | 8 +- doc/Sidekiq/Queue/UniqueExtension.html | 8 +- doc/Sidekiq/ScheduledSet.html | 8 +- doc/Sidekiq/ScheduledSet/UniqueExtension.html | 8 +- doc/Sidekiq/SortedEntry.html | 8 +- doc/Sidekiq/SortedEntry/UniqueExtension.html | 8 +- doc/Sidekiq/Worker.html | 18 +- doc/Sidekiq/Worker/ClassMethods.html | 95 +- doc/Sidekiq/Worker/Overrides.html | 97 +- .../Worker/Overrides/ClassMethods.html | 208 ++ doc/Sidekiq/Worker/SignletonOverrides.html | 204 ++ doc/SidekiqUniqueJobs.html | 336 +-- doc/SidekiqUniqueJobs/BatchDelete.html | 22 +- doc/SidekiqUniqueJobs/Changelog.html | 163 +- doc/SidekiqUniqueJobs/Cli.html | 30 +- doc/SidekiqUniqueJobs/Config.html | 148 +- doc/SidekiqUniqueJobs/Conflict.html | 8 +- doc/SidekiqUniqueJobs/Connection.html | 28 +- doc/SidekiqUniqueJobs/Deprecation.html | 8 +- doc/SidekiqUniqueJobs/Digests.html | 214 +- doc/SidekiqUniqueJobs/DuplicateLock.html | 8 +- doc/SidekiqUniqueJobs/DuplicateStrategy.html | 8 +- doc/SidekiqUniqueJobs/ExpiringDigests.html | 246 +++ doc/SidekiqUniqueJobs/InvalidArgument.html | 8 +- .../InvalidUniqueArguments.html | 14 +- doc/SidekiqUniqueJobs/InvalidWorker.html | 8 +- doc/SidekiqUniqueJobs/JSON.html | 8 +- doc/SidekiqUniqueJobs/Job.html | 36 +- doc/SidekiqUniqueJobs/Key.html | 140 +- doc/SidekiqUniqueJobs/Lock.html | 208 +- doc/SidekiqUniqueJobs/Lock/BaseLock.html | 8 +- .../Lock/ClientValidator.html | 8 +- .../Lock/ServerValidator.html | 8 +- .../Lock/UntilAndWhileExecuting.html | 8 +- doc/SidekiqUniqueJobs/Lock/UntilExecuted.html | 22 +- .../Lock/UntilExecuting.html | 18 +- doc/SidekiqUniqueJobs/Lock/UntilExpired.html | 16 +- doc/SidekiqUniqueJobs/Lock/Validator.html | 8 +- .../Lock/WhileExecuting.html | 28 +- .../Lock/WhileExecutingReject.html | 8 +- doc/SidekiqUniqueJobs/LockArgs.html | 620 +++--- doc/SidekiqUniqueJobs/LockConfig.html | 158 +- doc/SidekiqUniqueJobs/LockDigest.html | 526 +++-- doc/SidekiqUniqueJobs/LockInfo.html | 16 +- doc/SidekiqUniqueJobs/LockTTL.html | 386 ++-- doc/SidekiqUniqueJobs/LockTimeout.html | 320 ++- doc/SidekiqUniqueJobs/LockType.html | 1008 +++++++++ doc/SidekiqUniqueJobs/Locksmith.html | 129 +- doc/SidekiqUniqueJobs/Logging.html | 132 +- doc/SidekiqUniqueJobs/Logging/Middleware.html | 8 +- doc/SidekiqUniqueJobs/Middleware.html | 22 +- doc/SidekiqUniqueJobs/Middleware/Client.html | 25 +- doc/SidekiqUniqueJobs/Middleware/Server.html | 25 +- doc/SidekiqUniqueJobs/NoBlockGiven.html | 8 +- .../NoSuchNotificationError.html | 8 +- doc/SidekiqUniqueJobs/Normalizer.html | 8 +- doc/SidekiqUniqueJobs/NotUniqueWorker.html | 8 +- doc/SidekiqUniqueJobs/OnConflict.html | 8 +- doc/SidekiqUniqueJobs/OnConflict/Log.html | 8 +- .../OnConflict/NullStrategy.html | 8 +- doc/SidekiqUniqueJobs/OnConflict/Raise.html | 8 +- doc/SidekiqUniqueJobs/OnConflict/Reject.html | 289 +-- doc/SidekiqUniqueJobs/OnConflict/Replace.html | 10 +- .../OnConflict/Reschedule.html | 518 ++--- .../OnConflict/Strategy.html | 8 +- .../OptionsWithFallback.html | 20 +- doc/SidekiqUniqueJobs/Orphans.html | 8 +- doc/SidekiqUniqueJobs/Orphans/LuaReaper.html | 10 +- doc/SidekiqUniqueJobs/Orphans/Manager.html | 266 +-- doc/SidekiqUniqueJobs/Orphans/NullReaper.html | 8 +- doc/SidekiqUniqueJobs/Orphans/Observer.html | 8 +- doc/SidekiqUniqueJobs/Orphans/Reaper.html | 14 +- .../Orphans/ReaperResurrector.html | 10 +- doc/SidekiqUniqueJobs/Orphans/RubyReaper.html | 915 +++++++-- doc/SidekiqUniqueJobs/RSpec.html | 8 +- doc/SidekiqUniqueJobs/RSpec/Matchers.html | 8 +- .../Matchers/HaveValidSidekiqOptions.html | 8 +- doc/SidekiqUniqueJobs/Redis.html | 8 +- doc/SidekiqUniqueJobs/Redis/Entity.html | 8 +- doc/SidekiqUniqueJobs/Redis/Hash.html | 8 +- doc/SidekiqUniqueJobs/Redis/List.html | 8 +- doc/SidekiqUniqueJobs/Redis/Set.html | 8 +- doc/SidekiqUniqueJobs/Redis/SortedSet.html | 159 +- doc/SidekiqUniqueJobs/Redis/String.html | 36 +- doc/SidekiqUniqueJobs/RedisScript.html | 488 +++++ doc/SidekiqUniqueJobs/RedisScript/Client.html | 720 +++++++ doc/SidekiqUniqueJobs/RedisScript/Config.html | 376 ++++ doc/SidekiqUniqueJobs/RedisScript/DSL.html | 161 ++ .../RedisScript/DSL/ClassMethods.html | 432 ++++ .../RedisScript/Logging.html | 745 +++++++ .../RedisScript/LuaError.html | 662 ++++++ .../RedisScript/Misconfiguration.html | 149 ++ doc/SidekiqUniqueJobs/RedisScript/Script.html | 1251 ++++++++++++ .../RedisScript/Scripts.html | 1216 +++++++++++ .../RedisScript/Template.html | 403 ++++ doc/SidekiqUniqueJobs/RedisScript/Timing.html | 309 +++ doc/SidekiqUniqueJobs/Reflectable.html | 8 +- doc/SidekiqUniqueJobs/Reflections.html | 12 +- doc/SidekiqUniqueJobs/Script.html | 11 +- doc/SidekiqUniqueJobs/Script/Caller.html | 138 +- doc/SidekiqUniqueJobs/Server.html | 24 +- .../SidekiqWorkerMethods.html | 340 ++-- doc/SidekiqUniqueJobs/TimerTask.html | 933 ++++++++- doc/SidekiqUniqueJobs/Timing.html | 12 +- doc/SidekiqUniqueJobs/UniqueJobsError.html | 8 +- doc/SidekiqUniqueJobs/UnknownLock.html | 8 +- doc/SidekiqUniqueJobs/Unlockable.html | 8 +- doc/SidekiqUniqueJobs/UpdateVersion.html | 8 +- doc/SidekiqUniqueJobs/UpgradeLocks.html | 30 +- doc/SidekiqUniqueJobs/VersionCheck.html | 8 +- doc/SidekiqUniqueJobs/Web.html | 62 +- doc/SidekiqUniqueJobs/Web/Helpers.html | 418 ++-- doc/_index.html | 170 +- doc/class_list.html | 2 +- doc/file.CHANGELOG.html | 539 ++++- doc/file.LICENSE.html | 8 +- doc/file.README.html | 53 +- doc/frames.html | 2 +- doc/index.html | 53 +- doc/method_list.html | 1812 +++++++++++------ doc/top-level-namespace.html | 8 +- 130 files changed, 15778 insertions(+), 4138 deletions(-) create mode 100644 doc/Sidekiq/Worker/Overrides/ClassMethods.html create mode 100644 doc/Sidekiq/Worker/SignletonOverrides.html create mode 100644 doc/SidekiqUniqueJobs/ExpiringDigests.html create mode 100644 doc/SidekiqUniqueJobs/LockType.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Client.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Config.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/DSL.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/DSL/ClassMethods.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Logging.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/LuaError.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Misconfiguration.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Script.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Scripts.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Template.html create mode 100644 doc/SidekiqUniqueJobs/RedisScript/Timing.html diff --git a/doc/Array.html b/doc/Array.html index df5289c4d..ddd11e03c 100644 --- a/doc/Array.html +++ b/doc/Array.html @@ -6,7 +6,7 @@ Class: Array - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -222,9 +222,9 @@

diff --git a/doc/Hash.html b/doc/Hash.html index 0a7f1ab63..bef44d1a7 100644 --- a/doc/Hash.html +++ b/doc/Hash.html @@ -6,7 +6,7 @@ Class: Hash - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -654,9 +654,9 @@

diff --git a/doc/Sidekiq.html b/doc/Sidekiq.html index 7ccc55636..2ac05a6ac 100644 --- a/doc/Sidekiq.html +++ b/doc/Sidekiq.html @@ -6,7 +6,7 @@ Module: Sidekiq - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -220,21 +220,37 @@

31 32 33 -34 +34 +35 +36 +37 +38 +39 +40 +41 +42
# File 'lib/sidekiq_unique_jobs/testing.rb', line 24
 
-def self.use_options(tmp_config = {})
-  old_options = default_worker_options.dup
+def self.use_options(tmp_config = {}) # rubocop:disable Metrics/MethodLength
+  if respond_to?(:default_job_options)
+    default_job_options.clear
+    self.default_job_options = tmp_config
+  else
+    default_worker_options.clear
+    self.default_worker_options = tmp_config
+  end
 
-  default_worker_options.clear
-  self.default_worker_options = tmp_config
   yield
 ensure
-  default_worker_options.clear
-  self.default_worker_options = DEFAULT_WORKER_OPTIONS
-  self.default_worker_options = old_options
+  if respond_to?(:default_job_options)
+    default_job_options.clear
+    self.default_job_options = default_job_options
+  else
+    default_worker_options.clear
+    self.default_worker_options = DEFAULT_WORKER_OPTIONS
+  end
 end
@@ -246,9 +262,9 @@

diff --git a/doc/Sidekiq/Job.html b/doc/Sidekiq/Job.html index 3edf46cfb..58b6e9c42 100644 --- a/doc/Sidekiq/Job.html +++ b/doc/Sidekiq/Job.html @@ -6,7 +6,7 @@ Class: Sidekiq::Job - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -218,9 +218,9 @@

diff --git a/doc/Sidekiq/Job/UniqueExtension.html b/doc/Sidekiq/Job/UniqueExtension.html index bbe729c71..72a67b006 100644 --- a/doc/Sidekiq/Job/UniqueExtension.html +++ b/doc/Sidekiq/Job/UniqueExtension.html @@ -6,7 +6,7 @@ Module: Sidekiq::Job::UniqueExtension - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -215,9 +215,9 @@

diff --git a/doc/Sidekiq/JobRecord.html b/doc/Sidekiq/JobRecord.html index e1b8099ba..6d8637850 100644 --- a/doc/Sidekiq/JobRecord.html +++ b/doc/Sidekiq/JobRecord.html @@ -6,7 +6,7 @@ Class: Sidekiq::JobRecord - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -218,9 +218,9 @@

diff --git a/doc/Sidekiq/JobRecord/UniqueExtension.html b/doc/Sidekiq/JobRecord/UniqueExtension.html index e8868d73a..88e787b85 100644 --- a/doc/Sidekiq/JobRecord/UniqueExtension.html +++ b/doc/Sidekiq/JobRecord/UniqueExtension.html @@ -6,7 +6,7 @@ Module: Sidekiq::JobRecord::UniqueExtension - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -215,9 +215,9 @@

diff --git a/doc/Sidekiq/JobSet.html b/doc/Sidekiq/JobSet.html index dcba2f33c..78a3b243b 100644 --- a/doc/Sidekiq/JobSet.html +++ b/doc/Sidekiq/JobSet.html @@ -6,7 +6,7 @@ Class: Sidekiq::JobSet - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -311,9 +311,9 @@

diff --git a/doc/Sidekiq/JobSet/UniqueExtension.html b/doc/Sidekiq/JobSet/UniqueExtension.html index a00071e99..1e5eb2af0 100644 --- a/doc/Sidekiq/JobSet/UniqueExtension.html +++ b/doc/Sidekiq/JobSet/UniqueExtension.html @@ -6,7 +6,7 @@ Module: Sidekiq::JobSet::UniqueExtension - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -316,9 +316,9 @@

diff --git a/doc/Sidekiq/Queue.html b/doc/Sidekiq/Queue.html index 450773f0a..384d002f0 100644 --- a/doc/Sidekiq/Queue.html +++ b/doc/Sidekiq/Queue.html @@ -6,7 +6,7 @@ Class: Sidekiq::Queue - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -218,9 +218,9 @@

diff --git a/doc/Sidekiq/Queue/UniqueExtension.html b/doc/Sidekiq/Queue/UniqueExtension.html index 15e77c2dc..aa2426046 100644 --- a/doc/Sidekiq/Queue/UniqueExtension.html +++ b/doc/Sidekiq/Queue/UniqueExtension.html @@ -6,7 +6,7 @@ Module: Sidekiq::Queue::UniqueExtension - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -215,9 +215,9 @@

diff --git a/doc/Sidekiq/ScheduledSet.html b/doc/Sidekiq/ScheduledSet.html index 8423fc574..b4df72a38 100644 --- a/doc/Sidekiq/ScheduledSet.html +++ b/doc/Sidekiq/ScheduledSet.html @@ -6,7 +6,7 @@ Class: Sidekiq::ScheduledSet - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -252,9 +252,9 @@

diff --git a/doc/Sidekiq/ScheduledSet/UniqueExtension.html b/doc/Sidekiq/ScheduledSet/UniqueExtension.html index e4b72f8ee..dc43a5c32 100644 --- a/doc/Sidekiq/ScheduledSet/UniqueExtension.html +++ b/doc/Sidekiq/ScheduledSet/UniqueExtension.html @@ -6,7 +6,7 @@ Module: Sidekiq::ScheduledSet::UniqueExtension - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -251,9 +251,9 @@

diff --git a/doc/Sidekiq/SortedEntry.html b/doc/Sidekiq/SortedEntry.html index 2821b4be3..213fb253d 100644 --- a/doc/Sidekiq/SortedEntry.html +++ b/doc/Sidekiq/SortedEntry.html @@ -6,7 +6,7 @@ Class: Sidekiq::SortedEntry - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -235,9 +235,9 @@

diff --git a/doc/Sidekiq/SortedEntry/UniqueExtension.html b/doc/Sidekiq/SortedEntry/UniqueExtension.html index 600688a0e..c476b6242 100644 --- a/doc/Sidekiq/SortedEntry/UniqueExtension.html +++ b/doc/Sidekiq/SortedEntry/UniqueExtension.html @@ -6,7 +6,7 @@ Module: Sidekiq::SortedEntry::UniqueExtension - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -232,9 +232,9 @@

diff --git a/doc/Sidekiq/Worker.html b/doc/Sidekiq/Worker.html index 8f6113423..6daeb2046 100644 --- a/doc/Sidekiq/Worker.html +++ b/doc/Sidekiq/Worker.html @@ -6,7 +6,7 @@ Module: Sidekiq::Worker - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -73,7 +73,7 @@
Includes:
-
Overrides
+
Overrides, SignletonOverrides
@@ -102,7 +102,7 @@

Overview

- Modules: ClassMethods, Overrides + Modules: ClassMethods, Overrides, SignletonOverrides @@ -134,7 +134,7 @@

included - from Overrides + from SignletonOverrides @@ -185,6 +185,8 @@

+ +

Instance Method Details

@@ -201,7 +203,7 @@

Originally defined in module - Overrides + SignletonOverrides

@@ -270,9 +272,9 @@

diff --git a/doc/Sidekiq/Worker/ClassMethods.html b/doc/Sidekiq/Worker/ClassMethods.html index 547a693c8..3f375053c 100644 --- a/doc/Sidekiq/Worker/ClassMethods.html +++ b/doc/Sidekiq/Worker/ClassMethods.html @@ -6,7 +6,7 @@ Module: Sidekiq::Worker::ClassMethods - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -71,6 +71,11 @@ +
+
Includes:
+
Overrides::ClassMethods
+
+ @@ -78,14 +83,16 @@
Defined in:
-
lib/sidekiq_unique_jobs/testing.rb
+
lib/sidekiq_unique_jobs/testing.rb,
+ lib/sidekiq_unique_jobs/testing.rb
+

Overview

-

Adds class methods to Sidekiq::Worker

+

Prepends methods to Sidekiq::Worker

@@ -117,6 +124,11 @@

+ + included + from Overrides::ClassMethods + + @@ -158,6 +170,8 @@

+ +

Instance Method Details

@@ -172,6 +186,11 @@

+ + Originally defined in module + Overrides::ClassMethods + +

Clears the jobs for this worker and removes all locks

@@ -182,35 +201,7 @@

-
- - - - -
-
-
-
-64
-65
-66
-67
-68
-69
-70
-71
-
-
# File 'lib/sidekiq_unique_jobs/testing.rb', line 64
-
-def clear
-  jobs.each do |job|
-    SidekiqUniqueJobs::Unlockable.unlock(job)
-  end
-
-  Sidekiq::Queues[queue].clear
-  jobs.clear
-end
-
+

@@ -266,18 +257,24 @@

 
 
-51
-52
-53
-54
-55
-56
-57
-58
-59
+59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 -
# File 'lib/sidekiq_unique_jobs/testing.rb', line 51
+      
# File 'lib/sidekiq_unique_jobs/testing.rb', line 59
 
 def use_options(tmp_config = {})
   old_options = sidekiq_options_hash.dup
@@ -285,7 +282,13 @@ 

yield ensure - self.sidekiq_options_hash = Sidekiq::DEFAULT_WORKER_OPTIONS + self.sidekiq_options_hash = + if Sidekiq.respond_to?(:default_job_options) + Sidekiq.default_job_options + else + DEFAULT_WORKER_OPTIONS + end + sidekiq_options(old_options) end

@@ -298,9 +301,9 @@

diff --git a/doc/Sidekiq/Worker/Overrides.html b/doc/Sidekiq/Worker/Overrides.html index dc9a18981..40d629454 100644 --- a/doc/Sidekiq/Worker/Overrides.html +++ b/doc/Sidekiq/Worker/Overrides.html @@ -6,7 +6,7 @@ Module: Sidekiq::Worker::Overrides - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -98,7 +98,17 @@

Overview

-
+

Defined Under Namespace

+

+ + + Modules: ClassMethods + + + + +

+ @@ -116,29 +126,6 @@

  • - #clear_all ⇒ Object - - - - - - - - - - - - - -

    Clears all jobs for this worker and removes all locks.

    -
    - -
  • - - -
  • - - #sidekiq_options(options = {}) ⇒ void @@ -169,51 +156,7 @@

    Instance Method Details

    -

    - - #clear_allObject - - - - - -

    -
    -

    Clears all jobs for this worker and removes all locks

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -94
    -95
    -96
    -97
    -98
    -
    -
    # File 'lib/sidekiq_unique_jobs/testing.rb', line 94
    -
    -def clear_all
    -  super
    -
    -  SidekiqUniqueJobs::Digests.new.delete_by_pattern("*", count: 10_000)
    -end
    -
    -
    - -
    -

    +

    #sidekiq_options(options = {}) ⇒ void @@ -258,14 +201,14 @@

     
     
    -85
    -86
     87
     88
    -89
    +89 +90 +91 -
    # File 'lib/sidekiq_unique_jobs/testing.rb', line 85
    +      
    # File 'lib/sidekiq_unique_jobs/testing.rb', line 87
     
     def sidekiq_options(options = {})
       SidekiqUniqueJobs.validate_worker!(options) if SidekiqUniqueJobs.config.raise_on_config_error
    @@ -282,9 +225,9 @@ 

  • diff --git a/doc/Sidekiq/Worker/Overrides/ClassMethods.html b/doc/Sidekiq/Worker/Overrides/ClassMethods.html new file mode 100644 index 000000000..ae4c50cf2 --- /dev/null +++ b/doc/Sidekiq/Worker/Overrides/ClassMethods.html @@ -0,0 +1,208 @@ + + + + + + + Module: Sidekiq::Worker::Overrides::ClassMethods + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Sidekiq::Worker::Overrides::ClassMethods + + + +

    +
    + + + + + + + + + +
    +
    Included in:
    +
    ClassMethods
    +
    + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/testing.rb
    +
    + +
    + +

    Overview

    +
    +

    Prepends deletion of locks to clear

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + +
      + +
    • + + + #clear ⇒ Object + + + + + + + + + + + + + +

      Clears the jobs for this worker and removes all locks.

      +
      + +
    • + + +
    + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #clearObject + + + + + +

    +
    +

    Clears the jobs for this worker and removes all locks

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +100
    +101
    +102
    +103
    +104
    +105
    +106
    +
    +
    # File 'lib/sidekiq_unique_jobs/testing.rb', line 100
    +
    +def clear
    +  jobs.each do |job|
    +    SidekiqUniqueJobs::Unlockable.unlock(job)
    +  end
    +
    +  super
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Sidekiq/Worker/SignletonOverrides.html b/doc/Sidekiq/Worker/SignletonOverrides.html new file mode 100644 index 000000000..d704ed3b0 --- /dev/null +++ b/doc/Sidekiq/Worker/SignletonOverrides.html @@ -0,0 +1,204 @@ + + + + + + + Module: Sidekiq::Worker::SignletonOverrides + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Sidekiq::Worker::SignletonOverrides + + + +

    +
    + + + + + + + + + +
    +
    Included in:
    +
    Sidekiq::Worker
    +
    + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/testing.rb
    +
    + +
    + +

    Overview

    +
    +

    Prepends singleton methods to Sidekiq::Worker

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + +
      + +
    • + + + #clear_all ⇒ Object + + + + + + + + + + + + + +

      Clears all jobs for this worker and removes all locks.

      +
      + +
    • + + +
    + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #clear_allObject + + + + + +

    +
    +

    Clears all jobs for this worker and removes all locks

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +126
    +127
    +128
    +129
    +130
    +
    +
    # File 'lib/sidekiq_unique_jobs/testing.rb', line 126
    +
    +def clear_all
    +  super
    +
    +  SidekiqUniqueJobs::Digests.new.delete_by_pattern("*", count: 10_000)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs.html b/doc/SidekiqUniqueJobs.html index 5c3baeedd..46bc49405 100644 --- a/doc/SidekiqUniqueJobs.html +++ b/doc/SidekiqUniqueJobs.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -89,7 +89,7 @@
    Defined in:
    lib/sidekiq_unique_jobs/constants.rb,
    - lib/sidekiq_unique_jobs/cli.rb,
    lib/sidekiq_unique_jobs/job.rb,
    lib/sidekiq_unique_jobs/key.rb,
    lib/sidekiq_unique_jobs/web.rb,
    lib/sidekiq_unique_jobs/json.rb,
    lib/sidekiq_unique_jobs/lock.rb,
    lib/sidekiq_unique_jobs/redis.rb,
    lib/sidekiq_unique_jobs/config.rb,
    lib/sidekiq_unique_jobs/script.rb,
    lib/sidekiq_unique_jobs/server.rb,
    lib/sidekiq_unique_jobs/timing.rb,
    lib/sidekiq_unique_jobs/digests.rb,
    lib/sidekiq_unique_jobs/logging.rb,
    lib/sidekiq_unique_jobs/version.rb,
    lib/sidekiq_unique_jobs/lock_ttl.rb,
    lib/sidekiq_unique_jobs/changelog.rb,
    lib/sidekiq_unique_jobs/lock_args.rb,
    lib/sidekiq_unique_jobs/lock_info.rb,
    lib/sidekiq_unique_jobs/locksmith.rb,
    lib/sidekiq_unique_jobs/redis/set.rb,
    lib/sidekiq_unique_jobs/connection.rb,
    lib/sidekiq_unique_jobs/exceptions.rb,
    lib/sidekiq_unique_jobs/middleware.rb,
    lib/sidekiq_unique_jobs/normalizer.rb,
    lib/sidekiq_unique_jobs/redis/hash.rb,
    lib/sidekiq_unique_jobs/redis/list.rb,
    lib/sidekiq_unique_jobs/timer_task.rb,
    lib/sidekiq_unique_jobs/unlockable.rb,
    lib/sidekiq_unique_jobs/deprecation.rb,
    lib/sidekiq_unique_jobs/lock_config.rb,
    lib/sidekiq_unique_jobs/lock_digest.rb,
    lib/sidekiq_unique_jobs/on_conflict.rb,
    lib/sidekiq_unique_jobs/reflectable.rb,
    lib/sidekiq_unique_jobs/reflections.rb,
    lib/sidekiq_unique_jobs/web/helpers.rb,
    lib/sidekiq_unique_jobs/batch_delete.rb,
    lib/sidekiq_unique_jobs/lock_timeout.rb,
    lib/sidekiq_unique_jobs/redis/entity.rb,
    lib/sidekiq_unique_jobs/redis/string.rb,
    lib/sidekiq_unique_jobs/script/caller.rb,
    lib/sidekiq_unique_jobs/upgrade_locks.rb,
    lib/sidekiq_unique_jobs/version_check.rb,
    lib/sidekiq_unique_jobs/lock/base_lock.rb,
    lib/sidekiq_unique_jobs/lock/validator.rb,
    lib/sidekiq_unique_jobs/orphans/reaper.rb,
    lib/sidekiq_unique_jobs/rspec/matchers.rb,
    lib/sidekiq_unique_jobs/update_version.rb,
    lib/sidekiq_unique_jobs/on_conflict/log.rb,
    lib/sidekiq_unique_jobs/orphans/manager.rb,
    lib/sidekiq_unique_jobs/orphans/observer.rb,
    lib/sidekiq_unique_jobs/redis/sorted_set.rb,
    lib/sidekiq_unique_jobs/middleware/client.rb,
    lib/sidekiq_unique_jobs/middleware/server.rb,
    lib/sidekiq_unique_jobs/on_conflict/raise.rb,
    lib/sidekiq_unique_jobs/lock/until_expired.rb,
    lib/sidekiq_unique_jobs/on_conflict/reject.rb,
    lib/sidekiq_unique_jobs/orphans/lua_reaper.rb,
    lib/sidekiq_unique_jobs/lock/until_executed.rb,
    lib/sidekiq_unique_jobs/on_conflict/replace.rb,
    lib/sidekiq_unique_jobs/orphans/null_reaper.rb,
    lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb,
    lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb,
    lib/sidekiq_unique_jobs/lock/until_executing.rb,
    lib/sidekiq_unique_jobs/lock/while_executing.rb,
    lib/sidekiq_unique_jobs/on_conflict/strategy.rb,
    lib/sidekiq_unique_jobs/lock/client_validator.rb,
    lib/sidekiq_unique_jobs/lock/server_validator.rb,
    lib/sidekiq_unique_jobs/options_with_fallback.rb,
    lib/sidekiq_unique_jobs/on_conflict/reschedule.rb,
    lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb,
    lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb,
    lib/sidekiq_unique_jobs/logging/middleware_context.rb,
    lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb,
    lib/sidekiq_unique_jobs/lock/while_executing_reject.rb,
    lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb,
    lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
    + lib/sidekiq_unique_jobs/cli.rb,
    lib/sidekiq_unique_jobs/job.rb,
    lib/sidekiq_unique_jobs/key.rb,
    lib/sidekiq_unique_jobs/web.rb,
    lib/sidekiq_unique_jobs/json.rb,
    lib/sidekiq_unique_jobs/lock.rb,
    lib/sidekiq_unique_jobs/redis.rb,
    lib/sidekiq_unique_jobs/config.rb,
    lib/sidekiq_unique_jobs/script.rb,
    lib/sidekiq_unique_jobs/server.rb,
    lib/sidekiq_unique_jobs/timing.rb,
    lib/sidekiq_unique_jobs/digests.rb,
    lib/sidekiq_unique_jobs/logging.rb,
    lib/sidekiq_unique_jobs/version.rb,
    lib/sidekiq_unique_jobs/lock_ttl.rb,
    lib/sidekiq_unique_jobs/changelog.rb,
    lib/sidekiq_unique_jobs/lock_args.rb,
    lib/sidekiq_unique_jobs/lock_info.rb,
    lib/sidekiq_unique_jobs/lock_type.rb,
    lib/sidekiq_unique_jobs/locksmith.rb,
    lib/sidekiq_unique_jobs/redis/set.rb,
    lib/sidekiq_unique_jobs/connection.rb,
    lib/sidekiq_unique_jobs/exceptions.rb,
    lib/sidekiq_unique_jobs/middleware.rb,
    lib/sidekiq_unique_jobs/normalizer.rb,
    lib/sidekiq_unique_jobs/redis/hash.rb,
    lib/sidekiq_unique_jobs/redis/list.rb,
    lib/sidekiq_unique_jobs/timer_task.rb,
    lib/sidekiq_unique_jobs/unlockable.rb,
    lib/sidekiq_unique_jobs/deprecation.rb,
    lib/sidekiq_unique_jobs/lock_config.rb,
    lib/sidekiq_unique_jobs/lock_digest.rb,
    lib/sidekiq_unique_jobs/on_conflict.rb,
    lib/sidekiq_unique_jobs/reflectable.rb,
    lib/sidekiq_unique_jobs/reflections.rb,
    lib/sidekiq_unique_jobs/web/helpers.rb,
    lib/sidekiq_unique_jobs/batch_delete.rb,
    lib/sidekiq_unique_jobs/lock_timeout.rb,
    lib/sidekiq_unique_jobs/redis/entity.rb,
    lib/sidekiq_unique_jobs/redis/string.rb,
    lib/sidekiq_unique_jobs/redis_script.rb,
    lib/sidekiq_unique_jobs/script/caller.rb,
    lib/sidekiq_unique_jobs/upgrade_locks.rb,
    lib/sidekiq_unique_jobs/version_check.rb,
    lib/sidekiq_unique_jobs/lock/base_lock.rb,
    lib/sidekiq_unique_jobs/lock/validator.rb,
    lib/sidekiq_unique_jobs/orphans/reaper.rb,
    lib/sidekiq_unique_jobs/rspec/matchers.rb,
    lib/sidekiq_unique_jobs/update_version.rb,
    lib/sidekiq_unique_jobs/on_conflict/log.rb,
    lib/sidekiq_unique_jobs/orphans/manager.rb,
    lib/sidekiq_unique_jobs/expiring_digests.rb,
    lib/sidekiq_unique_jobs/orphans/observer.rb,
    lib/sidekiq_unique_jobs/redis/sorted_set.rb,
    lib/sidekiq_unique_jobs/redis_script/dsl.rb,
    lib/sidekiq_unique_jobs/middleware/client.rb,
    lib/sidekiq_unique_jobs/middleware/server.rb,
    lib/sidekiq_unique_jobs/on_conflict/raise.rb,
    lib/sidekiq_unique_jobs/lock/until_expired.rb,
    lib/sidekiq_unique_jobs/on_conflict/reject.rb,
    lib/sidekiq_unique_jobs/orphans/lua_reaper.rb,
    lib/sidekiq_unique_jobs/lock/until_executed.rb,
    lib/sidekiq_unique_jobs/on_conflict/replace.rb,
    lib/sidekiq_unique_jobs/orphans/null_reaper.rb,
    lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb,
    lib/sidekiq_unique_jobs/redis_script/client.rb,
    lib/sidekiq_unique_jobs/redis_script/config.rb,
    lib/sidekiq_unique_jobs/redis_script/script.rb,
    lib/sidekiq_unique_jobs/redis_script/timing.rb,
    lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb,
    lib/sidekiq_unique_jobs/lock/until_executing.rb,
    lib/sidekiq_unique_jobs/lock/while_executing.rb,
    lib/sidekiq_unique_jobs/on_conflict/strategy.rb,
    lib/sidekiq_unique_jobs/redis_script/logging.rb,
    lib/sidekiq_unique_jobs/redis_script/scripts.rb,
    lib/sidekiq_unique_jobs/lock/client_validator.rb,
    lib/sidekiq_unique_jobs/lock/server_validator.rb,
    lib/sidekiq_unique_jobs/options_with_fallback.rb,
    lib/sidekiq_unique_jobs/redis_script/template.rb,
    lib/sidekiq_unique_jobs/on_conflict/reschedule.rb,
    lib/sidekiq_unique_jobs/redis_script/lua_error.rb,
    lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb,
    lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb,
    lib/sidekiq_unique_jobs/logging/middleware_context.rb,
    lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb,
    lib/sidekiq_unique_jobs/lock/while_executing_reject.rb,
    lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb,
    lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
    @@ -124,11 +124,11 @@

    Overview

    - Modules: Connection, JSON, Job, Logging, Middleware, Normalizer, OnConflict, OptionsWithFallback, Orphans, RSpec, Redis, Reflectable, Script, SidekiqWorkerMethods, Timing, Unlockable, Web + Modules: Connection, JSON, Job, Logging, Middleware, Normalizer, OnConflict, OptionsWithFallback, Orphans, RSpec, Redis, RedisScript, Reflectable, Script, SidekiqWorkerMethods, Timing, Unlockable, Web - Classes: BatchDelete, Changelog, Cli, Config, Conflict, Deprecation, Digests, DuplicateLock, DuplicateStrategy, InvalidArgument, InvalidUniqueArguments, InvalidWorker, Key, Lock, LockArgs, LockConfig, LockDigest, LockInfo, LockTTL, LockTimeout, Locksmith, NoBlockGiven, NoSuchNotificationError, NotUniqueWorker, Reflections, Server, TimerTask, UniqueJobsError, UnknownLock, UpdateVersion, UpgradeLocks, VersionCheck + Classes: BatchDelete, Changelog, Cli, Config, Conflict, Deprecation, Digests, DuplicateLock, DuplicateStrategy, ExpiringDigests, InvalidArgument, InvalidUniqueArguments, InvalidWorker, Key, Lock, LockArgs, LockConfig, LockDigest, LockInfo, LockTTL, LockTimeout, LockType, Locksmith, NoBlockGiven, NoSuchNotificationError, NotUniqueWorker, Reflections, Server, TimerTask, UniqueJobsError, UnknownLock, UpdateVersion, UpgradeLocks, VersionCheck

    @@ -160,6 +160,7 @@

    :enabled, :lock_prefix, :logger, +:logger_enabled, :locks, :strategies, :debug_lua, @@ -204,7 +205,7 @@

    -
    "7.1.7"
    +
    "8.0.6"
    ARGS = @@ -246,6 +247,11 @@

    "uniquejobs:digests"
    +
    EXPIRING_DIGESTS = + +
    +
    "uniquejobs:expiring_digests"
    +
    ERRORS =
    @@ -693,6 +699,29 @@

    Set a new logger.

    + + + +
  • + + + .logging? ⇒ true, false + + + + + + + + + + + + + +

    Check if logging is enabled.

    +
    +
  • @@ -984,7 +1013,7 @@

  • - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -1072,8 +1101,8 @@

    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 19
     
     def config
    -  @config ||= reset!
    -end
    + @config ||= reset! # rubocop:disable ThreadSafety/InstanceVariableInClassMethod +end @@ -1213,25 +1242,25 @@

     
     
    -174
    -175
    -176
    -177
    -178
    -179
    -180
    -181
    -182
    +184 +185 +186 +187 +188 +189 +190 +191 +192 -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 174
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 184
     
     def configure(options = {})
       if block_given?
         yield config
       else
         options.each do |key, val|
    -      config.send("#{key}=", val)
    +      config.send(:"#{key}=", val)
         end
       end
     end
    @@ -1279,23 +1308,23 @@

     
     
    -244
    -245
    -246
    -247
    -248
    -249
    -250
    -251
    -252
    -253
     254
     255
     256
    -257
    +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 244
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 254
     
     def constantize(str)
       return str.class             if str.is_a?(Sidekiq::Worker) # sidekiq v6.x
    @@ -1388,12 +1417,12 @@ 

     
     
    -124
    -125
    -126
    +134 +135 +136

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 124
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 134
     
     def disable!(&block)
       toggle(false, &block)
    @@ -1458,12 +1487,12 @@ 

     
     
    -144
    -145
    -146
    +154 +155 +156

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 144
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 154
     
     def disabled?
       !enabled?
    @@ -1545,12 +1574,12 @@ 

     
     
    -112
    -113
    -114
    +122 +123 +124

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 112
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 122
     
     def enable!(&block)
       toggle(true, &block)
    @@ -1615,12 +1644,12 @@ 

     
     
    -134
    -135
    -136
    +144 +145 +146

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 134
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 144
     
     def enabled?
       config.enabled
    @@ -1672,15 +1701,15 @@ 

     
     
    -190
    -191
    -192
    +200 +201 +202

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 190
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 200
     
     def fetch_redis_version
    -  Sidekiq.redis_info["redis_version"]
    +  Sidekiq.default_configuration.redis_info["redis_version"]
     end
    @@ -1875,6 +1904,59 @@

    + + +
    +

    + + .logging?true, false + + + + + +

    +
    +

    Check if logging is enabled

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +80
    +81
    +82
    +
    +
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 80
    +
    +def logging?
    +  config.logger_enabled
    +end
    +
    @@ -1915,12 +1997,12 @@

     
     
    -210
    -211
    -212
    +220 +221 +222

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 210
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 220
     
     def now
       Time.now
    @@ -1968,12 +2050,12 @@ 

     
     
    -200
    -201
    -202
    +210 +211 +212

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 200
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 210
     
     def now_f
       now.to_f
    @@ -2027,12 +2109,12 @@ 

     
     
    -291
    -292
    -293
    +301 +302 +303

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 291
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 301
     
     def reflect
       yield reflections if block_given?
    @@ -2080,16 +2162,16 @@ 

     
     
    -280
    -281
    -282
    +290 +291 +292

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 280
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 290
     
     def reflections
    -  @reflections ||= Reflections.new
    -end
    + @reflections ||= Reflections.new # rubocop:disable ThreadSafety/InstanceVariableInClassMethod +end
    @@ -2137,16 +2219,16 @@

     
     
    -100
    -101
    -102
    +110 +111 +112

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 100
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 110
     
     def reset!
    -  @config = SidekiqUniqueJobs::Config.default
    -end
    + @config = SidekiqUniqueJobs::Config.default # rubocop:disable ThreadSafety/InstanceVariableInClassMethod +end
    @@ -2191,19 +2273,19 @@

     
     
    -263
    -264
    -265
    -266
    -267
    -268
    -269
    -270
    -271
    -272
    +273 +274 +275 +276 +277 +278 +279 +280 +281 +282

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 263
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 273
     
     def safe_constantize(str)
       constantize(str)
    @@ -2308,19 +2390,19 @@ 

     
     
    -153
    -154
    -155
    -156
    -157
    -158
    -159
    -160
    -161
    -162
    +163 +164 +165 +166 +167 +168 +169 +170 +171 +172

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 153
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 163
     
     def toggle(enabled)
       if block_given?
    @@ -2400,20 +2482,20 @@ 

     
     
    -82
    -83
    -84
    -85
    -86
    -87
    -88
    -89
    -90
    -91
    -92
    +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 82
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 92
     
     def use_config(tmp_config = {})
       raise ::ArgumentError, "#{name}.#{__method__} needs a block" unless block_given?
    @@ -2501,15 +2583,15 @@ 

     
     
    -221
    -222
    -223
    -224
    -225
    -226
    +231 +232 +233 +234 +235 +236

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 221
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 231
     
     def validate_worker(options)
       raise NotUniqueWorker, options unless (lock_type = options[LOCK])
    @@ -2583,13 +2665,13 @@ 

     
     
    -235
    -236
    -237
    -238
    +245 +246 +247 +248

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 235
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb', line 245
     
     def validate_worker!(options)
       lock_config = validate_worker(options)
    @@ -2666,7 +2748,7 @@ 

    Instance Method Details

    - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -2692,7 +2774,7 @@

  • - (Sidekiq::RedisConnection, ConnectionPool) + (Sidekiq::RedisConnection) @@ -2712,9 +2794,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/BatchDelete.html b/doc/SidekiqUniqueJobs/BatchDelete.html index 8d83cc85d..e55740db9 100644 --- a/doc/SidekiqUniqueJobs/BatchDelete.html +++ b/doc/SidekiqUniqueJobs/BatchDelete.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::BatchDelete - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -201,10 +201,10 @@

    %w[
    -  QUEUED
    -  PRIMED
    -  LOCKED
    -  INFO
    +  QUEUED
    +  PRIMED
    +  LOCKED
    +  INFO
     ].freeze
    @@ -592,7 +592,7 @@

  • - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -1514,7 +1514,7 @@

    - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -1540,7 +1540,7 @@

  • - (Sidekiq::RedisConnection, ConnectionPool) + (Sidekiq::RedisConnection) @@ -1644,9 +1644,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/Changelog.html b/doc/SidekiqUniqueJobs/Changelog.html index ead5e7f99..7ecc3edfc 100644 --- a/doc/SidekiqUniqueJobs/Changelog.html +++ b/doc/SidekiqUniqueJobs/Changelog.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Changelog - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -129,81 +129,6 @@

    Overview

    - -

    - Constant Summary - collapse -

    - -
    - -
    DEFAULT_COUNT = -
    -
    -

    Returns the number of matches to return by default.

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Integer) - - - - — -

      the number of matches to return by default

      -
      - -
    • - -
    - -
    -
    -
    1_000
    - -
    SCAN_PATTERN = -
    -
    -

    Returns the default pattern to use for matching.

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (String) - - - - — -

      the default pattern to use for matching

      -
      - -
    • - -
    - -
    -
    -
    "*"
    - -
    - - @@ -355,12 +280,12 @@

     
     
    -17
    -18
    -19
    +10 +11 +12

  • -
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 17
    +      
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 10
     
     def initialize
       super(CHANGELOGS)
    @@ -466,13 +391,13 @@ 

     
     
    -31
    -32
    -33
    -34
    +24 +25 +26 +27

    -
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 31
    +      
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 24
     
     def add(message:, digest:, job_id:, script:)
       message = dump_json(message: message, digest: digest, job_id: job_id, script: script)
    @@ -563,26 +488,18 @@ 

     
     
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    +37 +38 +39 +40 +41

    -
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 44
    -
    -def entries(pattern: SCAN_PATTERN, count: DEFAULT_COUNT)
    -  options = {}
    -  options[:match] = pattern
    -  options[:count] = count
    +      
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 37
     
    +def entries(pattern: SCAN_PATTERN, count: DEFAULT_COUNT)
       redis do |conn|
    -    conn.zscan_each(key, **options).to_a.map { |entry| load_json(entry[0]) }
    +    conn.zscan(key, match: pattern, count: count).to_a.map { |entry| load_json(entry[0]) }
       end
     end
    @@ -687,36 +604,38 @@

     
     
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
     63
     64
     65
    -66
    -67
    -68
    -69
    -70
    -71
    -72
    -73
    -74
    -75
    -76
    +66

    -
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 63
    +      
    # File 'lib/sidekiq_unique_jobs/changelog.rb', line 52
     
     def page(cursor: 0, pattern: "*", page_size: 100)
       redis do |conn|
    -    total_size, result = conn.multi do
    -      conn.zcard(key)
    -      conn.zscan(key, cursor, match: pattern, count: page_size)
    +    total_size, result = conn.multi do |pipeline|
    +      pipeline.zcard(key)
    +      pipeline.zscan(key, cursor, match: pattern, count: page_size)
         end
     
    -    [
    +    # NOTE: When debugging, check the last item in the returned array.
    +    [
           total_size.to_i,
           result[0].to_i, # next_cursor
    -      result[1].map { |entry| load_json(entry[0]) }, # entries
    -    ]
    +      result[1].map { |entry| load_json(entry) }.select { |entry| entry.is_a?(Hash) },
    +    ]
       end
     end
    @@ -729,9 +648,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Cli.html b/doc/SidekiqUniqueJobs/Cli.html index 708bb5a71..ee1161cc9 100644 --- a/doc/SidekiqUniqueJobs/Cli.html +++ b/doc/SidekiqUniqueJobs/Cli.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Cli - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -374,8 +374,6 @@

     
     
    -32
    -33
     34
     35
     36
    @@ -386,16 +384,14 @@ 

    41

    -
    # File 'lib/sidekiq_unique_jobs/cli.rb', line 32
    +      
    # File 'lib/sidekiq_unique_jobs/cli.rb', line 34
     
     def del(pattern)
       max_count = options[:count]
       if options[:dry_run]
    -    result = digests.entries(pattern: pattern, count: max_count)
    -    say "Would delete #{result.size} digests matching '#{pattern}'"
    +    count_entries_for_del(max_count, pattern)
       else
    -    deleted_count = digests.delete_by_pattern(pattern, count: max_count)
    -    say "Deleted #{deleted_count} digests matching '#{pattern}'"
    +    del_entries(max_count, pattern)
       end
     end
    @@ -432,15 +428,19 @@

    23 24 25 -26

    +26 +27 +28

    # File 'lib/sidekiq_unique_jobs/cli.rb', line 22
     
     def list(pattern = "*")
    -  entries = digests.entries(pattern: pattern, count: options[:count])
    -  say "Found #{entries.size} digests matching '#{pattern}':"
    -  print_in_columns(entries.sort) if entries.any?
    +  max_count = options[:count]
    +  say "Searching for regular digests"
    +  list_entries(digests.entries(pattern: pattern, count: max_count), pattern)
    +  say "Searching for expiring digests"
    +  list_entries(expiring_digests.entries(pattern: pattern, count: max_count), pattern)
     end
    @@ -452,9 +452,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Config.html b/doc/SidekiqUniqueJobs/Config.html index 8634b9414..7a849befe 100644 --- a/doc/SidekiqUniqueJobs/Config.html +++ b/doc/SidekiqUniqueJobs/Config.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Config - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -446,6 +446,38 @@

    nil
    +
    LOGGER_ENABLED = +
    +
    +

    Returns by default false (don't disable logger).

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + + — +

      by default false (don't disable logger)

      +
      + +
    • + +
    + +
    +
    +
    true
    +
    ENABLED =
    @@ -1153,10 +1185,6 @@

     
     
    -176
    -177
    -178
    -179
     180
     181
     182
    @@ -1174,10 +1202,15 @@ 

    194 195 196 -197

    +197 +198 +199 +200 +201 +202

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 176
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 180
     
     def self.default # rubocop:disable Metrics/MethodLength
       new(
    @@ -1186,6 +1219,7 @@ 

    ENABLED, PREFIX, Sidekiq.logger, + LOGGER_ENABLED, LOCKS, STRATEGIES, DEBUG_LUA, @@ -1299,16 +1333,16 @@

     
     
    -275
    -276
    -277
    -278
    -279
     280
    -281
    +281 +282 +283 +284 +285 +286

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 275
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 280
     
     def add_lock(name, klass)
       lock_sym = name.to_sym
    @@ -1409,16 +1443,16 @@ 

     
     
    -294
    -295
    -296
    -297
    -298
     299
    -300
    +300 +301 +302 +303 +304 +305

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 294
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 299
     
     def add_strategy(name, klass)
       strategy_sym = name.to_sym
    @@ -1474,12 +1508,12 @@ 

     
     
    -258
    -259
    -260
    +263 +264 +265

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 258
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 263
     
     def class_name
       @class_name ||= self.class.name
    @@ -1532,14 +1566,14 @@ 

     
     
    -246
    -247
    -248
    -249
    -250
    +251 +252 +253 +254 +255

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 246
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 251
     
     def default_lock_timeout
       warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \
    @@ -1609,14 +1643,14 @@ 

     
     
    -221
    -222
    -223
    -224
    -225
    +226 +227 +228 +229 +230

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 221
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 226
     
     def default_lock_timeout=(obj)
       warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \
    @@ -1671,14 +1705,14 @@ 

     
     
    -233
    -234
    -235
    -236
    -237
    +238 +239 +240 +241 +242

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 233
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 238
     
     def default_lock_ttl
       warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \
    @@ -1752,14 +1786,14 @@ 

     
     
    -207
    -208
    -209
    -210
    -211
    +212 +213 +214 +215 +216

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 207
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 212
     
     def default_lock_ttl=(obj)
       warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated." \
    @@ -1813,13 +1847,13 @@ 

     
     
    -308
    -309
    -310
    -311
    +313 +314 +315 +316

    -
    # File 'lib/sidekiq_unique_jobs/config.rb', line 308
    +      
    # File 'lib/sidekiq_unique_jobs/config.rb', line 313
     
     def redis_version
       self.current_redis_version = SidekiqUniqueJobs.fetch_redis_version if current_redis_version == REDIS_VERSION
    @@ -1835,9 +1869,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Conflict.html b/doc/SidekiqUniqueJobs/Conflict.html index 8125c2acd..2a0a0b60e 100644 --- a/doc/SidekiqUniqueJobs/Conflict.html +++ b/doc/SidekiqUniqueJobs/Conflict.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::Conflict - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -223,9 +223,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Connection.html b/doc/SidekiqUniqueJobs/Connection.html index 596ec6a5b..334a4dede 100644 --- a/doc/SidekiqUniqueJobs/Connection.html +++ b/doc/SidekiqUniqueJobs/Connection.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Connection - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -131,7 +131,7 @@

  • - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -163,7 +163,7 @@

    Instance Method Details

    - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -184,7 +184,7 @@

  • - (Sidekiq::RedisConnection, ConnectionPool) + (Sidekiq::RedisConnection) @@ -206,20 +206,14 @@

    15 16 17 -18 -19 -20 -21

  • +18
    # File 'lib/sidekiq_unique_jobs/connection.rb', line 14
     
    -def redis(r_pool = nil, &block)
    -  r_pool ||= defined?(redis_pool) ? redis_pool : r_pool
    -  if r_pool
    -    r_pool.with(&block)
    -  else
    -    Sidekiq.redis(&block)
    +def redis(_r_pool = nil, &block)
    +  Sidekiq.redis do |conn|
    +    conn.with(&block)
       end
     end
    @@ -232,9 +226,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Deprecation.html b/doc/SidekiqUniqueJobs/Deprecation.html index 459aad605..582a6564c 100644 --- a/doc/SidekiqUniqueJobs/Deprecation.html +++ b/doc/SidekiqUniqueJobs/Deprecation.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Deprecation - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -493,9 +493,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Digests.html b/doc/SidekiqUniqueJobs/Digests.html index ab18ca50c..a1631216c 100644 --- a/doc/SidekiqUniqueJobs/Digests.html +++ b/doc/SidekiqUniqueJobs/Digests.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Digests - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -128,7 +128,11 @@

    Overview

    +
    +

    Direct Known Subclasses

    +

    ExpiringDigests

    +

    Constant Summary @@ -201,6 +205,38 @@

    "*"
    +
    EMPTY_KEYS_SEGMENT = +
    +
    +

    Returns The empty runtime or queuetime keys.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array(String, String, String, String)) + + + + — +

      The empty runtime or queuetime keys.

      +
      + +
    • + +
    + +
    +
    +
    ["", "", "", ""].freeze
    + @@ -244,7 +280,7 @@

  • - #delete_by_digest(digest) ⇒ Object + #delete_by_digest(digest, queuetime: true, runtime: true) ⇒ Object @@ -267,7 +303,7 @@

  • - #delete_by_pattern(pattern, count: DEFAULT_COUNT) ⇒ Array<String> + #delete_by_pattern(pattern, count: DEFAULT_COUNT) ⇒ Hash<String,Float> @@ -313,7 +349,7 @@

  • - #initialize ⇒ Digests + #initialize(digests_key = DIGESTS) ⇒ Digests @@ -379,7 +415,7 @@

    Constructor Details

    - #initializeDigests + #initialize(digests_key = DIGESTS) ⇒ Digests @@ -401,15 +437,15 @@

     
     
    -17
    -18
    -19
    +20 +21 +22

  • -
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 17
    +      
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 20
     
    -def initialize
    -  super(DIGESTS)
    +def initialize(digests_key = DIGESTS)
    +  super(digests_key)
     end
    @@ -467,12 +503,12 @@

     
     
    -26
    -27
    -28
    +29 +30 +31

    -
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 26
    +      
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 29
     
     def add(digest)
       redis { |conn| conn.zadd(key, now_f, digest) }
    @@ -485,7 +521,7 @@ 

    - #delete_by_digest(digest) ⇒ Object + #delete_by_digest(digest, queuetime: true, runtime: true) ⇒ Object @@ -518,6 +554,40 @@

  • +
  • + + queuetime + + + (Boolean) + + + (defaults to: true) + + + — +

    Whether to delete queue locks.

    +
    + +
  • + +
  • + + runtime + + + (Boolean) + + + (defaults to: true) + + + — +

    Whether to delete run locks.

    +
    + +
  • + @@ -527,12 +597,6 @@

     
     
    -50
    -51
    -52
    -53
    -54
    -55
     56
     57
     58
    @@ -544,25 +608,17 @@ 

    64 65 66 -67 -68

    +67 -
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 50
    -
    -def delete_by_digest(digest) # rubocop:disable Metrics/MethodLength
    -  result, elapsed = timed do
    -    call_script(:delete_by_digest, [
    -                  digest,
    -                  "#{digest}:QUEUED",
    -                  "#{digest}:PRIMED",
    -                  "#{digest}:LOCKED",
    -                  "#{digest}:RUN",
    -                  "#{digest}:RUN:QUEUED",
    -                  "#{digest}:RUN:PRIMED",
    -                  "#{digest}:RUN:LOCKED",
    -                  key,
    -                ])
    +      
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 56
    +
    +def delete_by_digest(digest, queuetime: true, runtime: true)
    +  result, elapsed = timed do
    +    call_script(
    +      :delete_by_digest,
    +      queuetime_keys(queuetime ? digest : nil) + runtime_keys(runtime ? digest : nil) + [key],
    +    )
       end
     
       log_info("#{__method__}(#{digest}) completed in #{elapsed}ms")
    @@ -577,7 +633,7 @@ 

    - #delete_by_pattern(pattern, count: DEFAULT_COUNT) ⇒ Array<String> + #delete_by_pattern(pattern, count: DEFAULT_COUNT) ⇒ Hash<String,Float> @@ -634,12 +690,12 @@

  • - (Array<String>) + (Hash<String,Float>) — -

    with unique digests

    +

    Hash mapping of digest matching the given pattern and score

  • @@ -652,19 +708,19 @@

     
     
    -35
    -36
    -37
    -38
     39
     40
     41
     42
     43
    -44
    +44 +45 +46 +47 +48

    -
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 35
    +      
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 39
     
     def delete_by_pattern(pattern, count: DEFAULT_COUNT)
       result, elapsed = timed do
    @@ -761,31 +817,15 @@ 

     
     
    +77
     78
    -79
    -80
    -81
    -82
    -83
    -84
    -85
    -86
    -87
    -88
    +79

    -
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 78
    +      
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 77
     
     def entries(pattern: SCAN_PATTERN, count: DEFAULT_COUNT)
    -  options = {}
    -  options[:match] = pattern
    -  options[:count] = count
    -
    -  result = redis { |conn| conn.zscan_each(key, **options).to_a }
    -
    -  result.each_with_object({}) do |entry, hash|
    -    hash[entry[0]] = entry[1]
    -  end
    +  redis { |conn| conn.zscan(key, match: pattern, count: count).to_a }.to_h
     end
    @@ -889,35 +929,37 @@

     
     
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
     99
     100
     101
     102
     103
    -104
    -105
    -106
    -107
    -108
    -109
    -110
    -111
    -112
    +104

    -
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 99
    +      
    # File 'lib/sidekiq_unique_jobs/digests.rb', line 90
     
     def page(cursor: 0, pattern: SCAN_PATTERN, page_size: 100)
       redis do |conn|
    -    total_size, digests = conn.multi do
    -      conn.zcard(key)
    -      conn.zscan(key, cursor, match: pattern, count: page_size)
    +    total_size, digests = conn.multi do |pipeline|
    +      pipeline.zcard(key)
    +      pipeline.zscan(key, cursor, match: pattern, count: page_size)
         end
     
    -    [
    +    # NOTE: When debugging, check the last item in the returned array.
    +    [
           total_size.to_i,
           digests[0].to_i, # next_cursor
    -      digests[1].map { |digest, score| Lock.new(digest, time: score) }, # entries
    +      digests[1].each_slice(2).map { |digest, score| Lock.new(digest, time: score) }, # entries
         ]
       end
     end
    @@ -931,9 +973,9 @@

    diff --git a/doc/SidekiqUniqueJobs/DuplicateLock.html b/doc/SidekiqUniqueJobs/DuplicateLock.html index ac178e59a..e1e6320ad 100644 --- a/doc/SidekiqUniqueJobs/DuplicateLock.html +++ b/doc/SidekiqUniqueJobs/DuplicateLock.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::DuplicateLock - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -143,9 +143,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/DuplicateStrategy.html b/doc/SidekiqUniqueJobs/DuplicateStrategy.html index 41eb0d554..e4220761d 100644 --- a/doc/SidekiqUniqueJobs/DuplicateStrategy.html +++ b/doc/SidekiqUniqueJobs/DuplicateStrategy.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::DuplicateStrategy - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -143,9 +143,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/ExpiringDigests.html b/doc/SidekiqUniqueJobs/ExpiringDigests.html new file mode 100644 index 000000000..d04435c4b --- /dev/null +++ b/doc/SidekiqUniqueJobs/ExpiringDigests.html @@ -0,0 +1,246 @@ + + + + + + + Class: SidekiqUniqueJobs::ExpiringDigests + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: SidekiqUniqueJobs::ExpiringDigests + + + +

    +
    + +
    +
    Inherits:
    +
    + Digests + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/expiring_digests.rb
    +
    + +
    + +

    Overview

    +
    +

    Class ExpiringDigests provides access to the expiring digests used by until_expired locks

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initializeExpiringDigests + + + + + +

    +
    +

    Returns a new instance of ExpiringDigests.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +10
    +11
    +12
    +
    +
    # File 'lib/sidekiq_unique_jobs/expiring_digests.rb', line 10
    +
    +def initialize
    +  super(EXPIRING_DIGESTS)
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/InvalidArgument.html b/doc/SidekiqUniqueJobs/InvalidArgument.html index 8e494a193..d0e578380 100644 --- a/doc/SidekiqUniqueJobs/InvalidArgument.html +++ b/doc/SidekiqUniqueJobs/InvalidArgument.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::InvalidArgument - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -143,9 +143,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/InvalidUniqueArguments.html b/doc/SidekiqUniqueJobs/InvalidUniqueArguments.html index cdf3b5d6c..88e6e0d89 100644 --- a/doc/SidekiqUniqueJobs/InvalidUniqueArguments.html +++ b/doc/SidekiqUniqueJobs/InvalidUniqueArguments.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::InvalidUniqueArguments - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -222,14 +222,14 @@

    def initialize(options) given = options[:given] - worker_class = options[:worker_class] + job_class = options[:job_class] lock_args_method = options[:lock_args_method] - lock_args_meth = worker_class.method(lock_args_method) + lock_args_meth = job_class.method(lock_args_method) num_args = lock_args_meth.arity source_location = lock_args_meth.source_location super( - "#{worker_class}##{lock_args_method} takes #{num_args} arguments, received #{given.inspect}" \ + "#{job_class}##{lock_args_method} takes #{num_args} arguments, received #{given.inspect}" \ "\n\n" \ " #{source_location.join(':')}" ) @@ -245,9 +245,9 @@

    diff --git a/doc/SidekiqUniqueJobs/InvalidWorker.html b/doc/SidekiqUniqueJobs/InvalidWorker.html index add3f7197..93f40f6ef 100644 --- a/doc/SidekiqUniqueJobs/InvalidWorker.html +++ b/doc/SidekiqUniqueJobs/InvalidWorker.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::InvalidWorker - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -229,9 +229,9 @@

    diff --git a/doc/SidekiqUniqueJobs/JSON.html b/doc/SidekiqUniqueJobs/JSON.html index 62be69327..0db90dee2 100644 --- a/doc/SidekiqUniqueJobs/JSON.html +++ b/doc/SidekiqUniqueJobs/JSON.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::JSON - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -439,9 +439,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Job.html b/doc/SidekiqUniqueJobs/Job.html index 2a6a3344e..262105524 100644 --- a/doc/SidekiqUniqueJobs/Job.html +++ b/doc/SidekiqUniqueJobs/Job.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Job - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -173,7 +173,7 @@

    -

    Adds timeout, expiration, lock_args, lock_prefix and lock_digest to the sidekiq job hash.

    +

    Adds lock, timeout, expiration, lock_args, lock_prefix, and lock_digest to the sidekiq job hash.

    @@ -228,7 +228,7 @@

    -

    Adds timeout, expiration, lock_args, lock_prefix and lock_digest to the sidekiq job hash.

    +

    Adds lock, timeout, expiration, lock_args, lock_prefix, and lock_digest to the sidekiq job hash.

    @@ -285,16 +285,16 @@

     
     
    -21
     22
     23
     24
     25
     26
    -27
    +27 +28

    -
    # File 'lib/sidekiq_unique_jobs/job.rb', line 21
    +      
    # File 'lib/sidekiq_unique_jobs/job.rb', line 22
     
     def add_digest(item)
       add_lock_prefix(item)
    @@ -319,7 +319,7 @@ 

    -

    Adds timeout, expiration, lock_args, lock_prefix and lock_digest to the sidekiq job hash

    +

    Adds lock, timeout, expiration, lock_args, lock_prefix, and lock_digest to the sidekiq job hash

    @@ -355,13 +355,15 @@

    14 15 16 -17

    +17 +18
    # File 'lib/sidekiq_unique_jobs/job.rb', line 12
     
     def prepare(item)
       stringify_on_conflict_hash(item)
    +  add_lock_type(item)
       add_lock_timeout(item)
       add_lock_ttl(item)
       add_digest(item)
    @@ -419,16 +421,16 @@ 

     
     
    -21
     22
     23
     24
     25
     26
    -27
    +27 +28

    -
    # File 'lib/sidekiq_unique_jobs/job.rb', line 21
    +      
    # File 'lib/sidekiq_unique_jobs/job.rb', line 22
     
     def add_digest(item)
       add_lock_prefix(item)
    @@ -453,7 +455,7 @@ 

    -

    Adds timeout, expiration, lock_args, lock_prefix and lock_digest to the sidekiq job hash

    +

    Adds lock, timeout, expiration, lock_args, lock_prefix, and lock_digest to the sidekiq job hash

    @@ -489,13 +491,15 @@

    14 15 16 -17

    +17 +18
    # File 'lib/sidekiq_unique_jobs/job.rb', line 12
     
     def prepare(item)
       stringify_on_conflict_hash(item)
    +  add_lock_type(item)
       add_lock_timeout(item)
       add_lock_ttl(item)
       add_digest(item)
    @@ -510,9 +514,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Key.html b/doc/SidekiqUniqueJobs/Key.html index fc6bcceaf..821de53b7 100644 --- a/doc/SidekiqUniqueJobs/Key.html +++ b/doc/SidekiqUniqueJobs/Key.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Key - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -212,6 +212,34 @@

    Instance Attribute Summary collaps

    Returns the value of attribute digests.

    + + + +
  • + + + #expiring_digests ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute expiring_digests.

    +
    +
  • @@ -506,27 +534,29 @@

     
     
    -42
    -43
    -44
    -45
     46
     47
     48
     49
    -50
    +50 +51 +52 +53 +54 +55

    -
    # File 'lib/sidekiq_unique_jobs/key.rb', line 42
    +      
    # File 'lib/sidekiq_unique_jobs/key.rb', line 46
     
     def initialize(digest)
    -  @digest    = digest
    -  @queued    = suffixed_key("QUEUED")
    -  @primed    = suffixed_key("PRIMED")
    -  @locked    = suffixed_key("LOCKED")
    -  @info      = suffixed_key("INFO")
    -  @changelog = CHANGELOGS
    -  @digests   = DIGESTS
    +  @digest           = digest
    +  @queued           = suffixed_key("QUEUED")
    +  @primed           = suffixed_key("PRIMED")
    +  @locked           = suffixed_key("LOCKED")
    +  @info             = suffixed_key("INFO")
    +  @changelog        = CHANGELOGS
    +  @digests          = DIGESTS
    +  @expiring_digests = EXPIRING_DIGESTS
     end
    @@ -665,6 +695,48 @@

    + +
    +

    + + #expiring_digestsObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute expiring_digests.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +39
    +40
    +41
    +
    +
    # File 'lib/sidekiq_unique_jobs/key.rb', line 39
    +
    +def expiring_digests
    +  @expiring_digests
    +end
    +
    +
    + +

    @@ -896,12 +968,12 @@

     
     
    -74
    -75
    -76
    +79 +80 +81

    -
    # File 'lib/sidekiq_unique_jobs/key.rb', line 74
    +      
    # File 'lib/sidekiq_unique_jobs/key.rb', line 79
     
     def ==(other)
       digest == other.digest
    @@ -942,12 +1014,12 @@ 

     
     
    -63
    -64
    -65
    +68 +69 +70

    -
    # File 'lib/sidekiq_unique_jobs/key.rb', line 63
    +      
    # File 'lib/sidekiq_unique_jobs/key.rb', line 68
     
     def inspect
       digest
    @@ -999,15 +1071,15 @@ 

     
     
    -83
    -84
    -85
    +88 +89 +90

    -
    # File 'lib/sidekiq_unique_jobs/key.rb', line 83
    +      
    # File 'lib/sidekiq_unique_jobs/key.rb', line 88
     
     def to_a
    -  [digest, queued, primed, locked, info, changelog, digests]
    +  [digest, queued, primed, locked, info, changelog, digests, expiring_digests]
     end
    @@ -1052,12 +1124,12 @@

     
     
    -58
    -59
    -60
    +63 +64 +65

    -
    # File 'lib/sidekiq_unique_jobs/key.rb', line 58
    +      
    # File 'lib/sidekiq_unique_jobs/key.rb', line 63
     
     def to_s
       digest
    @@ -1072,9 +1144,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Lock.html b/doc/SidekiqUniqueJobs/Lock.html index 1062eff9e..45a7c0ac2 100644 --- a/doc/SidekiqUniqueJobs/Lock.html +++ b/doc/SidekiqUniqueJobs/Lock.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -639,7 +639,7 @@

  • - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -786,14 +786,20 @@

    48 49 50 -51

  • +51 +52 +53 +54
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 48
     
     def initialize(key, time: nil)
    -  @key        = get_key(key)
    -  @created_at = time.is_a?(Float) ? time : time.to_f
    +  @key = get_key(key)
    +  time = time.to_f unless time.is_a?(Float)
    +  return unless time.nonzero?
    +
    +  @created_at = time
     end
    @@ -1021,12 +1027,12 @@

     
     
    -152
    -153
    -154
    +155 +156 +157

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 152
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 155
     
     def all_jids
       (queued_jids + primed_jids + locked_jids).uniq
    @@ -1081,12 +1087,12 @@ 

     
     
    -259
    -260
    -261
    +262 +263 +264

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 259
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 262
     
     def changelog
       @changelog ||= Changelog.new
    @@ -1138,12 +1144,12 @@ 

     
     
    -194
    -195
    -196
    +197 +198 +199

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 194
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 197
     
     def changelogs
       changelog.entries(pattern: "*#{key.digest}*")
    @@ -1196,12 +1202,12 @@ 

     
     
    -140
    -141
    -142
    +143 +144 +145

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 140
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 143
     
     def created_at
       @created_at ||= changelogs.first&.[]("time")
    @@ -1253,23 +1259,23 @@ 

     
     
    -124
    -125
    -126
     127
     128
     129
     130
    -131
    +131 +132 +133 +134

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 124
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 127
     
     def del
       redis do |conn|
    -    conn.multi do
    -      conn.zrem(DIGESTS, key.digest)
    -      conn.del(key.digest, key.queued, key.primed, key.locked, key.info)
    +    conn.multi do |pipeline|
    +      pipeline.zrem(DIGESTS, key.digest)
    +      pipeline.del(key.digest, key.queued, key.primed, key.locked, key.info)
         end
       end
     end
    @@ -1328,12 +1334,12 @@

     
     
    -207
    -208
    -209
    +210 +211 +212

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 207
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 210
     
     def digest
       @digest ||= Redis::String.new(key.digest)
    @@ -1385,12 +1391,12 @@ 

     
     
    -247
    -248
    -249
    +250 +251 +252

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 247
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 250
     
     def info
       @info ||= LockInfo.new(key.info)
    @@ -1431,12 +1437,12 @@ 

     
     
    -285
    -286
    -287
    +288 +289 +290

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 285
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 288
     
     def inspect
       to_s
    @@ -1514,9 +1520,6 @@ 

     
     
    -63
    -64
    -65
     66
     67
     68
    @@ -1525,20 +1528,23 @@ 

    71 72 73 -74

    +74 +75 +76 +77

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 63
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 66
     
     def lock(job_id, lock_info = {})
       redis do |conn|
    -    conn.multi do
    -      conn.set(key.digest, job_id)
    -      conn.hset(key.locked, job_id, now_f)
    -      info.set(lock_info)
    -      conn.zadd(key.digests, now_f, key.digest)
    -      conn.zadd(key.changelog, now_f, changelog_json(job_id, "queue.lua", "Queued"))
    -      conn.zadd(key.changelog, now_f, changelog_json(job_id, "lock.lua", "Locked"))
    +    conn.multi do |pipeline|
    +      pipeline.set(key.digest, job_id)
    +      pipeline.hset(key.locked, job_id, now_f)
    +      info.set(lock_info, pipeline)
    +      add_digest_to_set(pipeline, lock_info)
    +      pipeline.zadd(key.changelog, now_f, changelog_json(job_id, "queue.lua", "Queued"))
    +      pipeline.zadd(key.changelog, now_f, changelog_json(job_id, "lock.lua", "Locked"))
         end
       end
     end
    @@ -1589,12 +1595,12 @@

     
     
    -237
    -238
    -239
    +240 +241 +242

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 237
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 240
     
     def locked
       @locked ||= Redis::Hash.new(key.locked)
    @@ -1680,12 +1686,12 @@ 

     
     
    -164
    -165
    -166
    +167 +168 +169

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 164
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 167
     
     def locked_jids(with_values: false)
       locked.entries(with_values: with_values)
    @@ -1746,14 +1752,14 @@ 

     
     
    -100
    -101
    -102
     103
    -104
    +104 +105 +106 +107

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 100
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 103
     
     def prime(job_id)
       redis do |conn|
    @@ -1807,12 +1813,12 @@ 

     
     
    -227
    -228
    -229
    +230 +231 +232

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 227
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 230
     
     def primed
       @primed ||= Redis::List.new(key.primed)
    @@ -1864,12 +1870,12 @@ 

     
     
    -184
    -185
    -186
    +187 +188 +189

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 184
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 187
     
     def primed_jids
       primed.entries
    @@ -1930,14 +1936,14 @@ 

     
     
    -85
    -86
    -87
     88
    -89
    +89 +90 +91 +92

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 85
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 88
     
     def queue(job_id)
       redis do |conn|
    @@ -1991,12 +1997,12 @@ 

     
     
    -217
    -218
    -219
    +220 +221 +222

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 217
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 220
     
     def queued
       @queued ||= Redis::List.new(key.queued)
    @@ -2048,12 +2054,12 @@ 

     
     
    -174
    -175
    -176
    +177 +178 +179

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 174
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 177
     
     def queued_jids
       queued.entries
    @@ -2066,7 +2072,7 @@ 

    - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -2092,7 +2098,7 @@

  • - (Sidekiq::RedisConnection, ConnectionPool) + (Sidekiq::RedisConnection) @@ -2145,9 +2151,6 @@

     
     
    -269
    -270
    -271
     272
     273
     274
    @@ -2156,10 +2159,13 @@ 

    277 278 279 -280

    +280 +281 +282 +283

  • -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 269
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 272
     
     def to_s
       <<~MESSAGE
    @@ -2252,12 +2258,12 @@ 

     
     
    -114
    -115
    -116
    +117 +118 +119

    -
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 114
    +      
    # File 'lib/sidekiq_unique_jobs/lock.rb', line 117
     
     def unlock(job_id)
       locked.del(job_id)
    @@ -2272,9 +2278,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Lock/BaseLock.html b/doc/SidekiqUniqueJobs/Lock/BaseLock.html index c018f4be9..26e8131fb 100644 --- a/doc/SidekiqUniqueJobs/Lock/BaseLock.html +++ b/doc/SidekiqUniqueJobs/Lock/BaseLock.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::BaseLock - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -1648,9 +1648,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/ClientValidator.html b/doc/SidekiqUniqueJobs/Lock/ClientValidator.html index 265d3059d..4adb1db02 100644 --- a/doc/SidekiqUniqueJobs/Lock/ClientValidator.html +++ b/doc/SidekiqUniqueJobs/Lock/ClientValidator.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::ClientValidator - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -267,9 +267,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/ServerValidator.html b/doc/SidekiqUniqueJobs/Lock/ServerValidator.html index da7b659a7..010871429 100644 --- a/doc/SidekiqUniqueJobs/Lock/ServerValidator.html +++ b/doc/SidekiqUniqueJobs/Lock/ServerValidator.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::ServerValidator - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -265,9 +265,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/UntilAndWhileExecuting.html b/doc/SidekiqUniqueJobs/Lock/UntilAndWhileExecuting.html index 6a7ce5bc7..da050d267 100644 --- a/doc/SidekiqUniqueJobs/Lock/UntilAndWhileExecuting.html +++ b/doc/SidekiqUniqueJobs/Lock/UntilAndWhileExecuting.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::UntilAndWhileExecuting - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -402,9 +402,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/UntilExecuted.html b/doc/SidekiqUniqueJobs/Lock/UntilExecuted.html index afc19a3d8..60ee7eea3 100644 --- a/doc/SidekiqUniqueJobs/Lock/UntilExecuted.html +++ b/doc/SidekiqUniqueJobs/Lock/UntilExecuted.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::UntilExecuted - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -265,16 +265,26 @@

    37 38 39 -40

    +40 +41 +42 +43 +44 +45
    # File 'lib/sidekiq_unique_jobs/lock/until_executed.rb', line 35
     
     def execute
    -  locksmith.execute do
    +  executed = locksmith.execute do
         yield
    +  ensure
         unlock_and_callback
       end
    +
    +  reflect(:execution_failed, item) unless executed
    +
    +  nil
     end
    @@ -385,9 +395,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/UntilExecuting.html b/doc/SidekiqUniqueJobs/Lock/UntilExecuting.html index 153220c51..4e32f9600 100644 --- a/doc/SidekiqUniqueJobs/Lock/UntilExecuting.html +++ b/doc/SidekiqUniqueJobs/Lock/UntilExecuting.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::UntilExecuting - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -259,7 +259,11 @@

    33 34 35 -36

    +36 +37 +38 +39 +40
    # File 'lib/sidekiq_unique_jobs/lock/until_executing.rb', line 33
    @@ -267,6 +271,10 @@ 

    def execute callback_safely if locksmith.unlock yield +rescue StandardError => ex + reflect(:execution_failed, item, ex) + locksmith.lock(wait: 1) + raise end

    @@ -360,9 +368,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/UntilExpired.html b/doc/SidekiqUniqueJobs/Lock/UntilExpired.html index a8451256d..70d2ac6ef 100644 --- a/doc/SidekiqUniqueJobs/Lock/UntilExpired.html +++ b/doc/SidekiqUniqueJobs/Lock/UntilExpired.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::UntilExpired - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -257,13 +257,17 @@

    35 36 -37

    +37 +38 +39
    # File 'lib/sidekiq_unique_jobs/lock/until_expired.rb', line 35
     
     def execute(&block)
    -  locksmith.execute(&block)
    +  executed = locksmith.execute(&block)
    +
    +  reflect(:execution_failed, item) unless executed
     end
    @@ -374,9 +378,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/Validator.html b/doc/SidekiqUniqueJobs/Lock/Validator.html index af968f5f3..df8248011 100644 --- a/doc/SidekiqUniqueJobs/Lock/Validator.html +++ b/doc/SidekiqUniqueJobs/Lock/Validator.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::Validator - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -785,9 +785,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Lock/WhileExecuting.html b/doc/SidekiqUniqueJobs/Lock/WhileExecuting.html index c7c34a8ca..17d8cdee7 100644 --- a/doc/SidekiqUniqueJobs/Lock/WhileExecuting.html +++ b/doc/SidekiqUniqueJobs/Lock/WhileExecuting.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::WhileExecuting - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -332,7 +332,7 @@

  • - #lock_type ⇒ Symbol + #lock_type ⇒ Symbol, NilClass @@ -972,7 +972,10 @@

    49 50 51 -52

  • +52 +53 +54 +55
    # File 'lib/sidekiq_unique_jobs/lock/while_executing.rb', line 41
    @@ -981,12 +984,15 @@ 

    with_logging_context do executed = locksmith.execute do yield - callback_safely if locksmith.unlock + item[JID] ensure - locksmith.unlock + unlock_and_callback end - call_strategy(origin: :server, &block) unless executed + unless executed + reflect(:execution_failed, item) + call_strategy(origin: :server, &block) + end end end

    @@ -1145,7 +1151,7 @@

    - #lock_typeSymbol + #lock_typeSymbol, NilClass @@ -1171,7 +1177,7 @@

  • - (Symbol) + (Symbol, NilClass) @@ -1851,9 +1857,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/Lock/WhileExecutingReject.html b/doc/SidekiqUniqueJobs/Lock/WhileExecutingReject.html index f1004dc08..a4687aee7 100644 --- a/doc/SidekiqUniqueJobs/Lock/WhileExecutingReject.html +++ b/doc/SidekiqUniqueJobs/Lock/WhileExecutingReject.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Lock::WhileExecutingReject - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -261,9 +261,9 @@

    diff --git a/doc/SidekiqUniqueJobs/LockArgs.html b/doc/SidekiqUniqueJobs/LockArgs.html index 077cf79a2..8f3aaf82b 100644 --- a/doc/SidekiqUniqueJobs/LockArgs.html +++ b/doc/SidekiqUniqueJobs/LockArgs.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::LockArgs - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -189,6 +189,37 @@

    Instance Attribute Summary collaps

    The sidekiq job hash.

    + + + +
  • + + + #job_class ⇒ Object + + + + + + + included + from SidekiqWorkerMethods + + + + + + + + + + + + + +

    Returns the value of attribute job_class.

    +
    +
  • @@ -296,7 +327,7 @@

  • - #default_lock_args_method ⇒ Object + #default_job_options ⇒ Hash<String, Object> @@ -310,7 +341,7 @@

    -

    The global worker options defined in Sidekiq directly.

    +

    The globally default worker options configured from Sidekiq.

  • @@ -319,7 +350,7 @@

  • - #default_worker_options ⇒ Hash<String, Object> + #default_lock_args_method ⇒ Object @@ -333,7 +364,7 @@

    -

    The globally default worker options configured from Sidekiq.

    +

    The global worker options defined in Sidekiq directly.

  • @@ -436,34 +467,16 @@

  • - #lock_args ⇒ Array + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker - - - - - - - - -

    The unique arguments to use for creating a lock.

    -
    - -
  • - - -
  • - - - #lock_args_disabled? ⇒ true, false - - - - + + included + from SidekiqWorkerMethods + @@ -473,7 +486,7 @@

    -

    Checks if the worker class has disabled lock_args.

    +

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

  • @@ -482,12 +495,17 @@

  • - #lock_args_enabled? ⇒ true, false + #job_method_defined?(method_sym) ⇒ true, false + + included + from SidekiqWorkerMethods + + @@ -496,7 +514,7 @@

    -

    Checks if the worker class has enabled lock_args.

    +

    Avoids duplicating worker_class.respond_to? in multiple places.

  • @@ -505,12 +523,17 @@

  • - #lock_args_method ⇒ Object + #job_options ⇒ Hash + + included + from SidekiqWorkerMethods + + @@ -519,7 +542,7 @@

    -

    The method to use for filtering unique arguments.

    +

    Wraps #get_sidekiq_options to always work with a hash.

  • @@ -528,7 +551,7 @@

  • - #lock_args_method_valid? ⇒ true, false + #lock_args ⇒ Array @@ -542,7 +565,7 @@

    -

    Validate that the lock_args_method is acceptable.

    +

    The unique arguments to use for creating a lock.

  • @@ -551,17 +574,12 @@

  • - #log_debug(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #lock_args_disabled? ⇒ true, false - - included - from Logging - - @@ -570,7 +588,7 @@

    -

    Logs a message at debug level.

    +

    Checks if the worker class has disabled lock_args.

  • @@ -579,17 +597,12 @@

  • - #log_error(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #lock_args_enabled? ⇒ true, false - - included - from Logging - - @@ -598,7 +611,7 @@

    -

    Logs a message at error level.

    +

    Checks if the worker class has enabled lock_args.

  • @@ -607,17 +620,12 @@

  • - #log_fatal(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #lock_args_method ⇒ Object - - included - from Logging - - @@ -626,7 +634,7 @@

    -

    Logs a message at fatal level.

    +

    The method to use for filtering unique arguments.

  • @@ -635,17 +643,12 @@

  • - #log_info(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #lock_args_method_valid? ⇒ true, false - - included - from Logging - - @@ -654,7 +657,7 @@

    -

    Logs a message at info level.

    +

    Validate that the lock_args_method is acceptable.

  • @@ -663,7 +666,7 @@

  • - #log_warn(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #log_debug(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -671,7 +674,7 @@

    included - from Logging + from Logging @@ -682,7 +685,7 @@

    -

    Logs a message at warn level.

    +

    Logs a message at debug level.

  • @@ -691,7 +694,7 @@

  • - #logger ⇒ Logger + #log_error(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -699,7 +702,7 @@

    included - from Logging + from Logging @@ -710,7 +713,7 @@

    -

    A convenience method for using the configured gem logger.

    +

    Logs a message at error level.

  • @@ -719,7 +722,7 @@

  • - #logging_context ⇒ Hash + #log_fatal(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -727,7 +730,7 @@

    included - from Logging + from Logging @@ -738,7 +741,7 @@

    -

    Setup some variables to add to each log line.

    +

    Logs a message at fatal level.

  • @@ -747,7 +750,7 @@

  • - #sidekiq_worker_class? ⇒ true, false + #log_info(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -755,7 +758,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -766,7 +769,7 @@

    -

    Tests that the.

    +

    Logs a message at info level.

  • @@ -775,7 +778,7 @@

  • - #with_configured_loggers_context { ... } ⇒ void + #log_warn(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -783,7 +786,7 @@

    included - from Logging + from Logging @@ -794,7 +797,7 @@

    -

    Attempt to setup context aware logging for the given logger.

    +

    Logs a message at warn level.

  • @@ -803,7 +806,7 @@

  • - #with_logging_context ⇒ void + #logger ⇒ Logger @@ -811,7 +814,7 @@

    included - from Logging + from Logging @@ -822,7 +825,7 @@

    -

    Wraps the middleware logic with context aware logging.

    +

    A convenience method for using the configured gem logger.

  • @@ -831,7 +834,7 @@

  • - #worker_class ⇒ Sidekiq::Worker + #logging_context ⇒ Hash @@ -839,7 +842,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -850,7 +853,7 @@

    -

    The Sidekiq::Worker implementation.

    +

    Setup some variables to add to each log line.

  • @@ -859,7 +862,7 @@

  • - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #sidekiq_job_class? ⇒ true, false @@ -867,7 +870,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -878,7 +881,7 @@

    -

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

    +

    Tests that the.

  • @@ -887,7 +890,7 @@

  • - #worker_method_defined?(method_sym) ⇒ true, false + #with_configured_loggers_context { ... } ⇒ void @@ -895,7 +898,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -906,7 +909,7 @@

    -

    Avoids duplicating worker_class.respond_to? in multiple places.

    +

    Attempt to setup context aware logging for the given logger.

  • @@ -915,7 +918,7 @@

  • - #worker_options ⇒ Hash + #with_logging_context ⇒ void @@ -923,7 +926,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -934,7 +937,7 @@

    -

    Wraps #get_sidekiq_options to always work with a hash.

    +

    Wraps the middleware logic with context aware logging.

  • @@ -1006,9 +1009,9 @@

    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 28
     
     def initialize(item)
    -  @item         = item
    -  @worker_class = item[CLASS]
    -  @args         = item[ARGS]
    +  @item = item
    +  @args = item[ARGS]
    +  self.job_class = item[CLASS]
     end
    @@ -1121,6 +1124,35 @@

    + + +
    +

    + + #job_classObject + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the value of attribute job_class.

    + + +
    +
    +
    + + +
    +
    + @@ -1331,9 +1363,9 @@

    -

    +

    - #default_lock_args_methodObject + #default_job_optionsHash<String, Object> @@ -1341,13 +1373,26 @@

    -

    The global worker options defined in Sidekiq directly

    +

    The globally default worker options configured from Sidekiq

    +

    Returns:

    +
      + +
    • + + + (Hash<String, Object>) + + + +
    • + +
    @@ -1355,17 +1400,23 @@

     
     
    -108
    -109
    -110
    -111
    +119 +120 +121 +122 +123 +124 +125

    @@ -1373,9 +1424,9 @@

    -

    +

    - #default_worker_optionsHash<String, Object> + #default_lock_args_methodObject @@ -1383,26 +1434,13 @@

    -

    The globally default worker options configured from Sidekiq

    +

    The global worker options defined in Sidekiq directly

    -

    Returns:

    -
      - -
    • - - - (Hash<String, Object>) - - - -
    • - -

    -
    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 108
    +      
    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 119
     
    -def default_lock_args_method
    -  default_worker_options[LOCK_ARGS_METHOD] ||
    -    default_worker_options[UNIQUE_ARGS_METHOD]
    +def default_job_options
    +  @default_job_options ||= if Sidekiq.respond_to?(:default_job_options)
    +    Sidekiq.default_job_options.stringify_keys
    +  else
    +    Sidekiq.default_worker_options.stringify_keys
    +  end
     end
    @@ -1410,15 +1448,17 @@

     
     
    -119
    -120
    -121
    +108 +109 +110 +111

    @@ -1549,7 +1589,7 @@

    — -

    unfiltered unless SidekiqWorkerMethods#worker_method_defined?

    + @@ -1590,13 +1630,13 @@

    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 88
     
     def filter_by_symbol(args)
    -  return args unless worker_method_defined?(lock_args_method)
    +  return args unless job_method_defined?(lock_args_method)
     
    -  worker_class.send(lock_args_method, args)
    +  job_class.send(lock_args_method, args)
     rescue ArgumentError
       raise SidekiqUniqueJobs::InvalidUniqueArguments,
             given: args,
    -        worker_class: worker_class,
    +        job_class: job_class,
             lock_args_method: lock_args_method
     end
    @@ -1703,6 +1743,131 @@

    -
    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 119
    +      
    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 108
     
    -def default_worker_options
    -  @default_worker_options ||= Sidekiq.default_worker_options.stringify_keys
    +def default_lock_args_method
    +  default_job_options[LOCK_ARGS_METHOD] ||
    +    default_job_options[UNIQUE_ARGS_METHOD]
     end
    +
    + +
    +

    + + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Attempt to constantize a string worker_class argument, always +failing back to the original argument when the constant can't be found

    + + +
    +
    +
    + +

    Returns:

    + + +
    +
    + +
    +

    + + #job_method_defined?(method_sym) ⇒ true, false + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Avoids duplicating worker_class.respond_to? in multiple places

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    +
    + +
    +

    + + #job_optionsHash + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Wraps #get_sidekiq_options to always work with a hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +

      of the worker class sidekiq options

      +
      + +
    • + +
    + +
    @@ -1755,7 +1920,7 @@

    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 36
     
     def lock_args
    -  @lock_args ||= filtered_args
    +  @lock_args ||= filtered_args || []
     end
    @@ -1908,9 +2073,9 @@

    # File 'lib/sidekiq_unique_jobs/lock_args.rb', line 100
     
     def lock_args_method
    -  @lock_args_method ||= worker_options.slice(LOCK_ARGS_METHOD, UNIQUE_ARGS_METHOD).values.first
    -  @lock_args_method ||= :lock_args if worker_method_defined?(:lock_args)
    -  @lock_args_method ||= :unique_args if worker_method_defined?(:unique_args)
    +  @lock_args_method ||= job_options.slice(LOCK_ARGS_METHOD, UNIQUE_ARGS_METHOD).values.first
    +  @lock_args_method ||= :lock_args if job_method_defined?(:lock_args)
    +  @lock_args_method ||= :unique_args if job_method_defined?(:unique_args)
       @lock_args_method ||= default_lock_args_method
     end
    @@ -2401,9 +2566,9 @@

    -

    +

    - #sidekiq_worker_class?true, false + #sidekiq_job_class?true, false @@ -2411,7 +2576,7 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    @@ -2434,7 +2599,7 @@

    — -

    if worker_class responds to get_sidekiq_options

    +

    if job_class responds to get_sidekiq_options

    @@ -2447,7 +2612,7 @@

    — -

    if worker_class does not respond to get_sidekiq_options

    +

    if job_class does not respond to get_sidekiq_options

    @@ -2538,171 +2703,6 @@

    -

    -

    - -
    -

    - - #worker_classSidekiq::Worker - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    The Sidekiq::Worker implementation

    - - -
    -
    -
    - -

    Returns:

    - - -
    -
    - -
    -

    - - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Attempt to constantize a string worker_class argument, always -failing back to the original argument when the constant can't be found

    - - -
    -
    -
    - -

    Returns:

    - - -
    -
    - -
    -

    - - #worker_method_defined?(method_sym) ⇒ true, false - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Avoids duplicating worker_class.respond_to? in multiple places

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (true, false) - - - -
    • - -
    - -
    -
    - -
    -

    - - #worker_optionsHash - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Wraps #get_sidekiq_options to always work with a hash

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Hash) - - - - — -

      of the worker class sidekiq options

      -
      - -
    • - -
    -
    @@ -2711,9 +2711,9 @@

    diff --git a/doc/SidekiqUniqueJobs/LockConfig.html b/doc/SidekiqUniqueJobs/LockConfig.html index 5a2ef79ce..2c46be152 100644 --- a/doc/SidekiqUniqueJobs/LockConfig.html +++ b/doc/SidekiqUniqueJobs/LockConfig.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::LockConfig - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -163,7 +163,7 @@

    Instance Attribute Summary collaps
  • - #limit ⇒ Object + #job ⇒ Object @@ -182,7 +182,7 @@

    Instance Attribute Summary collaps -

    Returns the value of attribute limit.

    +

    Returns the value of attribute job.

  • @@ -191,7 +191,7 @@

    Instance Attribute Summary collaps
  • - #lock_info ⇒ Object + #limit ⇒ Object @@ -210,7 +210,7 @@

    Instance Attribute Summary collaps -

    Returns the value of attribute lock_info.

    +

    Returns the value of attribute limit.

  • @@ -219,7 +219,7 @@

    Instance Attribute Summary collaps
  • - #on_conflict ⇒ Object + #lock_info ⇒ Object @@ -238,7 +238,7 @@

    Instance Attribute Summary collaps -

    Returns the value of attribute on_conflict.

    +

    Returns the value of attribute lock_info.

  • @@ -247,7 +247,7 @@

    Instance Attribute Summary collaps
  • - #pttl ⇒ Object + #on_conflict ⇒ Object @@ -266,7 +266,7 @@

    Instance Attribute Summary collaps -

    Returns the value of attribute pttl.

    +

    Returns the value of attribute on_conflict.

  • @@ -275,7 +275,7 @@

    Instance Attribute Summary collaps
  • - #timeout ⇒ Object + #pttl ⇒ Object @@ -294,7 +294,7 @@

    Instance Attribute Summary collaps -

    Returns the value of attribute timeout.

    +

    Returns the value of attribute pttl.

  • @@ -303,7 +303,7 @@

    Instance Attribute Summary collaps
  • - #ttl ⇒ Integer? + #timeout ⇒ Object @@ -322,7 +322,7 @@

    Instance Attribute Summary collaps -

    The time (in milliseconds) to live after successful.

    +

    Returns the value of attribute timeout.

  • @@ -331,7 +331,7 @@

    Instance Attribute Summary collaps
  • - #type ⇒ Object + #ttl ⇒ Integer? @@ -350,7 +350,7 @@

    Instance Attribute Summary collaps -

    Returns the value of attribute type.

    +

    The time (in milliseconds) to live after successful.

  • @@ -359,7 +359,7 @@

    Instance Attribute Summary collaps
  • - #worker ⇒ Object + #type ⇒ Object @@ -378,7 +378,7 @@

    Instance Attribute Summary collaps -

    Returns the value of attribute worker.

    +

    Returns the value of attribute type.

  • @@ -642,7 +642,7 @@

    def initialize(job_hash = {}) @type = job_hash[LOCK]&.to_sym - @worker = SidekiqUniqueJobs.safe_constantize(job_hash[CLASS]) + @job = SidekiqUniqueJobs.safe_constantize(job_hash[CLASS]) @limit = job_hash.fetch(LOCK_LIMIT, 1)&.to_i @timeout = job_hash.fetch(LOCK_TIMEOUT, 0)&.to_i @ttl = job_hash.fetch(LOCK_TTL) { job_hash.fetch(LOCK_EXPIRATION, nil) }.to_i @@ -707,6 +707,48 @@

    + +
    +

    + + #jobObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute job.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +18
    +19
    +20
    +
    +
    # File 'lib/sidekiq_unique_jobs/lock_config.rb', line 18
    +
    +def job
    +  @job
    +end
    +
    +
    + +

    @@ -1017,48 +1059,6 @@

    - - -
    -

    - - #workerObject (readonly) - - - - - -

    -
    -

    Returns the value of attribute worker.

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -18
    -19
    -20
    -
    -
    # File 'lib/sidekiq_unique_jobs/lock_config.rb', line 18
    -
    -def worker
    -  @worker
    -end
    -
    -
    - @@ -1289,14 +1289,20 @@

    115 116 117 -118

    +118 +119 +120 +121
    # File 'lib/sidekiq_unique_jobs/lock_config.rb', line 115
     
     def on_client_conflict
    -  @on_client_conflict ||= on_conflict["client"] if on_conflict.is_a?(Hash)
    -  @on_client_conflict ||= on_conflict
    +  @on_client_conflict ||= if on_conflict.is_a?(Hash)
    +    on_conflict["client"] || on_conflict[:client]
    +  else
    +    on_conflict
    +  end
     end
    @@ -1328,17 +1334,23 @@

     
     
    -121
    -122
    -123
    -124
    +124 +125 +126 +127 +128 +129 +130

    -
    # File 'lib/sidekiq_unique_jobs/lock_config.rb', line 121
    +      
    # File 'lib/sidekiq_unique_jobs/lock_config.rb', line 124
     
     def on_server_conflict
    -  @on_server_conflict ||= on_conflict["server"] if on_conflict.is_a?(Hash)
    -  @on_server_conflict ||= on_conflict
    +  @on_server_conflict ||= if on_conflict.is_a?(Hash)
    +    on_conflict["server"] || on_conflict[:server]
    +  else
    +    on_conflict
    +  end
     end
    @@ -1456,9 +1468,9 @@

    diff --git a/doc/SidekiqUniqueJobs/LockDigest.html b/doc/SidekiqUniqueJobs/LockDigest.html index ef0f82807..15060fdbe 100644 --- a/doc/SidekiqUniqueJobs/LockDigest.html +++ b/doc/SidekiqUniqueJobs/LockDigest.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::LockDigest - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -189,6 +189,37 @@

    Instance Attribute Summary collaps

    The sidekiq job hash.

    + + + +
  • + + + #job_class ⇒ Object + + + + + + + included + from SidekiqWorkerMethods + + + + + + + + + + + + + +

    Returns the value of attribute job_class.

    +
    +
  • @@ -375,7 +406,7 @@

  • - #default_worker_options ⇒ Hash<Symbol, Object> + #default_job_options ⇒ Hash<Symbol, Object> @@ -383,7 +414,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -451,12 +482,17 @@

  • - #lock_digest ⇒ String + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker + + included + from SidekiqWorkerMethods + + @@ -465,7 +501,7 @@

    -

    Memoized lock_digest.

    +

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

  • @@ -474,7 +510,7 @@

  • - #log_debug(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #job_method_defined?(method_sym) ⇒ true, false @@ -482,7 +518,7 @@

    included - from Logging + from SidekiqWorkerMethods @@ -493,7 +529,7 @@

    -

    Logs a message at debug level.

    +

    Avoids duplicating worker_class.respond_to? in multiple places.

  • @@ -502,7 +538,7 @@

  • - #log_error(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #job_options ⇒ Hash @@ -510,7 +546,7 @@

    included - from Logging + from SidekiqWorkerMethods @@ -521,7 +557,7 @@

    -

    Logs a message at error level.

    +

    Wraps #get_sidekiq_options to always work with a hash.

  • @@ -530,17 +566,12 @@

  • - #log_fatal(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #lock_digest ⇒ String - - included - from Logging - - @@ -549,7 +580,7 @@

    -

    Logs a message at fatal level.

    +

    Memoized lock_digest.

  • @@ -558,7 +589,7 @@

  • - #log_info(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #log_debug(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -566,7 +597,7 @@

    included - from Logging + from Logging @@ -577,7 +608,7 @@

    -

    Logs a message at info level.

    +

    Logs a message at debug level.

  • @@ -586,7 +617,7 @@

  • - #log_warn(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #log_error(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -594,7 +625,7 @@

    included - from Logging + from Logging @@ -605,7 +636,7 @@

    -

    Logs a message at warn level.

    +

    Logs a message at error level.

  • @@ -614,7 +645,7 @@

  • - #logger ⇒ Logger + #log_fatal(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -622,7 +653,7 @@

    included - from Logging + from Logging @@ -633,7 +664,7 @@

    -

    A convenience method for using the configured gem logger.

    +

    Logs a message at fatal level.

  • @@ -642,7 +673,7 @@

  • - #logging_context ⇒ Hash + #log_info(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -650,7 +681,7 @@

    included - from Logging + from Logging @@ -661,7 +692,7 @@

    -

    Setup some variables to add to each log line.

    +

    Logs a message at info level.

  • @@ -670,7 +701,7 @@

  • - #sidekiq_worker_class? ⇒ true, false + #log_warn(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -678,7 +709,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -689,7 +720,7 @@

    -

    Tests that the.

    +

    Logs a message at warn level.

  • @@ -698,34 +729,16 @@

  • - #unique_across_queues? ⇒ true, false + #logger ⇒ Logger - - - - - - - - -

    Checks if we should disregard the queue when creating the unique digest.

    -
    - -
  • - - -
  • - - - #unique_across_workers? ⇒ true, false - - - - + + included + from Logging + @@ -735,7 +748,7 @@

    -

    Checks if we should disregard the worker when creating the unique digest.

    +

    A convenience method for using the configured gem logger.

  • @@ -744,7 +757,7 @@

  • - #with_configured_loggers_context { ... } ⇒ void + #logging_context ⇒ Hash @@ -752,7 +765,7 @@

    included - from Logging + from Logging @@ -763,7 +776,7 @@

    -

    Attempt to setup context aware logging for the given logger.

    +

    Setup some variables to add to each log line.

  • @@ -772,7 +785,7 @@

  • - #with_logging_context ⇒ void + #sidekiq_job_class? ⇒ true, false @@ -780,7 +793,7 @@

    included - from Logging + from SidekiqWorkerMethods @@ -791,7 +804,7 @@

    -

    Wraps the middleware logic with context aware logging.

    +

    Tests that the.

  • @@ -800,17 +813,12 @@

  • - #worker_class ⇒ Sidekiq::Worker + #unique_across_queues? ⇒ true, false - - included - from SidekiqWorkerMethods - - @@ -819,7 +827,7 @@

    -

    The Sidekiq::Worker implementation.

    +

    Checks if we should disregard the queue when creating the unique digest.

  • @@ -828,17 +836,12 @@

  • - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #unique_across_workers? ⇒ true, false - - included - from SidekiqWorkerMethods - - @@ -847,7 +850,7 @@

    -

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

    +

    Checks if we should disregard the worker when creating the unique digest.

  • @@ -856,7 +859,7 @@

  • - #worker_method_defined?(method_sym) ⇒ true, false + #with_configured_loggers_context { ... } ⇒ void @@ -864,7 +867,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -875,7 +878,7 @@

    -

    Avoids duplicating worker_class.respond_to? in multiple places.

    +

    Attempt to setup context aware logging for the given logger.

  • @@ -884,7 +887,7 @@

  • - #worker_options ⇒ Hash + #with_logging_context ⇒ void @@ -892,7 +895,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -903,7 +906,7 @@

    -

    Wraps #get_sidekiq_options to always work with a hash.

    +

    Wraps the middleware logic with context aware logging.

  • @@ -976,11 +979,11 @@

    # File 'lib/sidekiq_unique_jobs/lock_digest.rb', line 38
     
     def initialize(item)
    -  @item         = item
    -  @worker_class = item[CLASS]
    -  @lock_args    = item.slice(LOCK_ARGS, UNIQUE_ARGS).values.first # TODO: Deprecate UNIQUE_ARGS
    -  @lock_prefix  = item.slice(LOCK_PREFIX, UNIQUE_PREFIX).values.first # TODO: Deprecate UNIQUE_PREFIX
    -end
    + @item = item + @lock_args = item[LOCK_ARGS] || item[UNIQUE_ARGS] # TODO: Deprecate UNIQUE_ARGS + @lock_prefix = item[LOCK_PREFIX] || item[UNIQUE_PREFIX] # TODO: Deprecate UNIQUE_PREFIX + self.job_class = item[CLASS] +end

  • @@ -1106,6 +1109,35 @@

    + +
    +

    + + #job_classObject + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the value of attribute job_class.

    + + +
    +
    +
    + + +
    +
    + +

    @@ -1449,7 +1481,7 @@

    # File 'lib/sidekiq_unique_jobs/lock_digest.rb', line 53
     
     def create_digest
    -  digest = OpenSSL::Digest::MD5.hexdigest(dump_json(digestable_hash))
    +  digest = OpenSSL::Digest::MD5.hexdigest(dump_json(digestable_hash.sort))
       "#{lock_prefix}:#{digest}"
     end
    @@ -1458,9 +1490,9 @@

    -

    +

    - #default_worker_optionsHash<Symbol, Object> + #default_job_optionsHash<Symbol, Object> @@ -1468,7 +1500,7 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    @@ -1558,6 +1590,131 @@

    +

    + +
    +

    + + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Attempt to constantize a string worker_class argument, always +failing back to the original argument when the constant can't be found

    + + +
    +
    +
    + +

    Returns:

    + + +
    +
    + +
    +

    + + #job_method_defined?(method_sym) ⇒ true, false + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Avoids duplicating worker_class.respond_to? in multiple places

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    +
    + +
    +

    + + #job_optionsHash + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Wraps #get_sidekiq_options to always work with a hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +

      of the worker class sidekiq options

      +
      + +
    • + +
    + +
    @@ -2047,9 +2204,9 @@

    -

    +

    - #sidekiq_worker_class?true, false + #sidekiq_job_class?true, false @@ -2057,7 +2214,7 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    @@ -2080,7 +2237,7 @@

    — -

    if worker_class responds to get_sidekiq_options

    +

    if job_class responds to get_sidekiq_options

    @@ -2093,7 +2250,7 @@

    — -

    if worker_class does not respond to get_sidekiq_options

    +

    if job_class does not respond to get_sidekiq_options

    @@ -2149,7 +2306,7 @@

    # File 'lib/sidekiq_unique_jobs/lock_digest.rb', line 69
     
     def unique_across_queues?
    -  item[UNIQUE_ACROSS_QUEUES] || worker_options[UNIQUE_ACROSS_QUEUES]
    +  item[UNIQUE_ACROSS_QUEUES] || job_options[UNIQUE_ACROSS_QUEUES]
     end
    @@ -2202,7 +2359,7 @@

    # File 'lib/sidekiq_unique_jobs/lock_digest.rb', line 75
     
     def unique_across_workers?
    -  item[UNIQUE_ACROSS_WORKERS] || worker_options[UNIQUE_ACROSS_WORKERS]
    +  item[UNIQUE_ACROSS_WORKERS] || job_options[UNIQUE_ACROSS_WORKERS]
     end
    @@ -2290,171 +2447,6 @@

    -

    -

    - -
    -

    - - #worker_classSidekiq::Worker - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    The Sidekiq::Worker implementation

    - - -
    -
    -
    - -

    Returns:

    - - -
    -
    - -
    -

    - - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Attempt to constantize a string worker_class argument, always -failing back to the original argument when the constant can't be found

    - - -
    -
    -
    - -

    Returns:

    - - -
    -
    - -
    -

    - - #worker_method_defined?(method_sym) ⇒ true, false - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Avoids duplicating worker_class.respond_to? in multiple places

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (true, false) - - - -
    • - -
    - -
    -
    - -
    -

    - - #worker_optionsHash - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Wraps #get_sidekiq_options to always work with a hash

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Hash) - - - - — -

      of the worker class sidekiq options

      -
      - -
    • - -
    -
    @@ -2463,9 +2455,9 @@

    diff --git a/doc/SidekiqUniqueJobs/LockInfo.html b/doc/SidekiqUniqueJobs/LockInfo.html index c756a3bf1..784c225b9 100644 --- a/doc/SidekiqUniqueJobs/LockInfo.html +++ b/doc/SidekiqUniqueJobs/LockInfo.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::LockInfo - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -215,7 +215,7 @@

  • - #set(obj) ⇒ Hash + #set(obj, pipeline = nil) ⇒ Hash @@ -466,7 +466,7 @@

    - #set(obj) ⇒ Hash + #set(obj, pipeline = nil) ⇒ Hash @@ -546,13 +546,13 @@

    # File 'lib/sidekiq_unique_jobs/lock_info.rb', line 58
     
    -def set(obj)
    +def set(obj, pipeline = nil)
       return unless SidekiqUniqueJobs.config.lock_info
       raise InvalidArgument, "argument `obj` (#{obj}) needs to be a hash" unless obj.is_a?(Hash)
     
       json = dump_json(obj)
       @value = load_json(json)
    -  super(json)
    +  super(json, pipeline)
       value
     end
    @@ -618,9 +618,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/LockTTL.html b/doc/SidekiqUniqueJobs/LockTTL.html index 81c3c8d15..aad39554a 100644 --- a/doc/SidekiqUniqueJobs/LockTTL.html +++ b/doc/SidekiqUniqueJobs/LockTTL.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::LockTTL - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -161,6 +161,37 @@

    Instance Attribute Summary collaps

    Returns the value of attribute item.

    + + + +
  • + + + #job_class ⇒ Object + + + + + + + included + from SidekiqWorkerMethods + + + + + + + + + + + + + +

    Returns the value of attribute job_class.

    +
    +
  • @@ -263,7 +294,7 @@

  • - #default_worker_options ⇒ Hash<Symbol, Object> + #default_job_options ⇒ Hash<Symbol, Object> @@ -271,7 +302,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -316,30 +347,7 @@

  • - #scheduled_at ⇒ Float - - - - - - - - - - - - - -

    The time a job is scheduled.

    -
    - -
  • - - -
  • - - - #sidekiq_worker_class? ⇒ true, false + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker @@ -347,7 +355,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -358,7 +366,7 @@

    -

    Tests that the.

    +

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

  • @@ -367,12 +375,17 @@

  • - #time_until_scheduled ⇒ Integer + #job_method_defined?(method_sym) ⇒ true, false + + included + from SidekiqWorkerMethods + + @@ -381,7 +394,7 @@

    -

    Calculates the time until the job is scheduled starting from now.

    +

    Avoids duplicating worker_class.respond_to? in multiple places.

  • @@ -390,7 +403,7 @@

  • - #worker_class ⇒ Sidekiq::Worker + #job_options ⇒ Hash @@ -398,7 +411,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -409,7 +422,7 @@

    -

    The Sidekiq::Worker implementation.

    +

    Wraps #get_sidekiq_options to always work with a hash.

  • @@ -418,17 +431,12 @@

  • - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #scheduled_at ⇒ Float - - included - from SidekiqWorkerMethods - - @@ -437,7 +445,7 @@

    -

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

    +

    The time a job is scheduled.

  • @@ -446,7 +454,7 @@

  • - #worker_method_defined?(method_sym) ⇒ true, false + #sidekiq_job_class? ⇒ true, false @@ -454,7 +462,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -465,7 +473,7 @@

    -

    Avoids duplicating worker_class.respond_to? in multiple places.

    +

    Tests that the.

  • @@ -474,17 +482,12 @@

  • - #worker_options ⇒ Hash + #time_until_scheduled ⇒ Integer - - included - from SidekiqWorkerMethods - - @@ -493,7 +496,7 @@

    -

    Wraps #get_sidekiq_options to always work with a hash.

    +

    Calculates the time until the job is scheduled starting from now.

  • @@ -617,8 +620,8 @@

    # File 'lib/sidekiq_unique_jobs/lock_ttl.rb', line 35
     
     def initialize(item)
    -  @item         = item
    -  @worker_class = item[CLASS]
    +  @item = item
    +  self.job_class = item[CLASS]
     end
    @@ -672,6 +675,35 @@

    + + +
    +

    + + #job_classObject + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the value of attribute job_class.

    + + +
    +
    +
    + + +
    +
    + @@ -856,9 +888,9 @@

    def calculate ttl = item[LOCK_TTL] - ttl ||= worker_options[LOCK_TTL] + ttl ||= job_options[LOCK_TTL] ttl ||= item[LOCK_EXPIRATION] # TODO: Deprecate at some point - ttl ||= worker_options[LOCK_EXPIRATION] # TODO: Deprecate at some point + ttl ||= job_options[LOCK_EXPIRATION] # TODO: Deprecate at some point ttl ||= SidekiqUniqueJobs.config.lock_ttl ttl && (ttl.to_i + time_until_scheduled) end

  • @@ -868,9 +900,9 @@

    -

    +

    - #default_worker_optionsHash<Symbol, Object> + #default_job_optionsHash<Symbol, Object> @@ -878,7 +910,7 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    @@ -908,17 +940,23 @@

    -

    +

    - #scheduled_atFloat + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker + + Originally defined in module + SidekiqWorkerMethods + +

    -

    The time a job is scheduled

    +

    Attempt to constantize a string worker_class argument, always +failing back to the original argument when the constant can't be found

    @@ -931,43 +969,21 @@

  • - (Float) + (Sidekiq::Worker) - — -

    the exact unix time the job is scheduled at

    -
    -
  • -

    - - - - -
    -
    -
    -
    -54
    -55
    -56
    -
    -
    # File 'lib/sidekiq_unique_jobs/lock_ttl.rb', line 54
    -
    -def scheduled_at
    -  @scheduled_at ||= item[AT]
    -end
    -
    +
    -

    +

    - #sidekiq_worker_class?true, false + #job_method_defined?(method_sym) ⇒ true, false @@ -975,12 +991,12 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    -

    Tests that the

    +

    Avoids duplicating worker_class.respond_to? in multiple places

    @@ -993,27 +1009,10 @@

  • - (true) - - - - — -

    if worker_class responds to get_sidekiq_options

    -
    - -
  • - -
  • - - - (false) + (true, false) - — -

    if worker_class does not respond to get_sidekiq_options

    -
    -
  • @@ -1022,17 +1021,22 @@

    -

    +

    - #time_until_scheduledInteger + #job_optionsHash + + Originally defined in module + SidekiqWorkerMethods + +

    -

    Calculates the time until the job is scheduled starting from now

    +

    Wraps #get_sidekiq_options to always work with a hash

    @@ -1045,60 +1049,33 @@

  • - (Integer) + (Hash) — -

    the number of seconds until job is scheduled

    +

    of the worker class sidekiq options

  • -

    - - - - -
    -
    -
    -
    -46
    -47
    -48
    -49
    -50
    -
    -
    # File 'lib/sidekiq_unique_jobs/lock_ttl.rb', line 46
    -
    -def time_until_scheduled
    -  return 0 unless scheduled_at
    -
    -  scheduled_at.to_i - Time.now.utc.to_i
    -end
    -
    +
    -

    +

    - #worker_classSidekiq::Worker + #scheduled_atFloat - - Originally defined in module - SidekiqWorkerMethods - -

    -

    The Sidekiq::Worker implementation

    +

    The time a job is scheduled

    @@ -1111,21 +1088,43 @@

  • - (Sidekiq::Worker) + (Float) + + — +

    the exact unix time the job is scheduled at

    +
  • -

    +
    + + + + +
    +
    +
    +
    +54
    +55
    +56
    +
    +
    # File 'lib/sidekiq_unique_jobs/lock_ttl.rb', line 54
    +
    +def scheduled_at
    +  @scheduled_at ||= item[AT]
    +end
    +
    -

    +

    - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #sidekiq_job_class?true, false @@ -1133,13 +1132,12 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    -

    Attempt to constantize a string worker_class argument, always -failing back to the original argument when the constant can't be found

    +

    Tests that the

    @@ -1152,50 +1150,27 @@

  • - (Sidekiq::Worker) + (true) -
  • - - - -

    -
    - -
    -

    - - #worker_method_defined?(method_sym) ⇒ true, false - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Avoids duplicating worker_class.respond_to? in multiple places

    - - -
    + — +

    if job_class responds to get_sidekiq_options

    -
    - -

    Returns:

    -
      + +
    • - (true, false) + (false) + — +

      if job_class does not respond to get_sidekiq_options

      +
      +
    @@ -1204,22 +1179,17 @@

    -

    +

    - #worker_optionsHash + #time_until_scheduledInteger - - Originally defined in module - SidekiqWorkerMethods - -

    -

    Wraps #get_sidekiq_options to always work with a hash

    +

    Calculates the time until the job is scheduled starting from now

    @@ -1232,19 +1202,41 @@

  • - (Hash) + (Integer) — -

    of the worker class sidekiq options

    +

    the number of seconds until job is scheduled

  • -

    +
    + + + + +
    +
    +
    +
    +46
    +47
    +48
    +49
    +50
    +
    +
    # File 'lib/sidekiq_unique_jobs/lock_ttl.rb', line 46
    +
    +def time_until_scheduled
    +  return 0 unless scheduled_at
    +
    +  scheduled_at.to_i - Time.now.utc.to_i
    +end
    +
    @@ -1252,9 +1244,9 @@

    diff --git a/doc/SidekiqUniqueJobs/LockTimeout.html b/doc/SidekiqUniqueJobs/LockTimeout.html index b58b16fb5..19bcc3f10 100644 --- a/doc/SidekiqUniqueJobs/LockTimeout.html +++ b/doc/SidekiqUniqueJobs/LockTimeout.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::LockTimeout - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -161,6 +161,37 @@

    Instance Attribute Summary collaps

    Returns the value of attribute item.

    + + + +
  • + + + #job_class ⇒ Object + + + + + + + included + from SidekiqWorkerMethods + + + + + + + + + + + + + +

    Returns the value of attribute job_class.

    +
    +
  • @@ -263,30 +294,7 @@

  • - #default_lock_timeout ⇒ Integer? - - - - - - - - - - - - - -

    The configured default_lock_timeout.

    -
    - -
  • - - -
  • - - - #default_worker_options ⇒ Hash<Symbol, Object> + #default_job_options ⇒ Hash<Symbol, Object> @@ -294,7 +302,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -314,15 +322,13 @@

  • - #initialize(item) ⇒ LockTimeout + #default_lock_timeout ⇒ Integer? - constructor - @@ -330,7 +336,7 @@

    -

    A new instance of LockTimeout.

    +

    The configured default_lock_timeout.

  • @@ -339,17 +345,14 @@

  • - #sidekiq_worker_class? ⇒ true, false + #initialize(item) ⇒ LockTimeout - - included - from SidekiqWorkerMethods - + constructor @@ -358,7 +361,7 @@

    -

    Tests that the.

    +

    A new instance of LockTimeout.

  • @@ -367,7 +370,7 @@

  • - #worker_class ⇒ Sidekiq::Worker + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker @@ -375,7 +378,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -386,7 +389,7 @@

    -

    The Sidekiq::Worker implementation.

    +

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

  • @@ -395,7 +398,7 @@

  • - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #job_method_defined?(method_sym) ⇒ true, false @@ -403,7 +406,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -414,7 +417,7 @@

    -

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

    +

    Avoids duplicating worker_class.respond_to? in multiple places.

  • @@ -423,7 +426,7 @@

  • - #worker_method_defined?(method_sym) ⇒ true, false + #job_options ⇒ Hash @@ -431,7 +434,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -442,7 +445,7 @@

    -

    Avoids duplicating worker_class.respond_to? in multiple places.

    +

    Wraps #get_sidekiq_options to always work with a hash.

  • @@ -451,7 +454,7 @@

  • - #worker_options ⇒ Hash + #sidekiq_job_class? ⇒ true, false @@ -459,7 +462,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -470,7 +473,7 @@

    -

    Wraps #get_sidekiq_options to always work with a hash.

    +

    Tests that the.

  • @@ -594,8 +597,8 @@

    # File 'lib/sidekiq_unique_jobs/lock_timeout.rb', line 32
     
     def initialize(item)
    -  @item         = item
    -  @worker_class = item[CLASS]
    +  @item = item
    +  self.job_class = item[CLASS]
     end
    @@ -649,6 +652,35 @@

    + + +
    +

    + + #job_classObject + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the value of attribute job_class.

    + + +
    +
    +
    + + +
    +
    + @@ -828,14 +860,54 @@

    # File 'lib/sidekiq_unique_jobs/lock_timeout.rb', line 44
     
     def calculate
    -  timeout = default_worker_options[LOCK_TIMEOUT]
    +  timeout = default_job_options[LOCK_TIMEOUT]
       timeout = default_lock_timeout if default_lock_timeout
    -  timeout = worker_options[LOCK_TIMEOUT] if worker_options.key?(LOCK_TIMEOUT)
    +  timeout = job_options[LOCK_TIMEOUT] if job_options.key?(LOCK_TIMEOUT)
       timeout
     end
    + + +
    +

    + + #default_job_optionsHash<Symbol, Object> + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the default worker options from Sidekiq

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash<Symbol, Object>) + + + +
    • + +
    + +
    @@ -899,9 +971,9 @@

    -

    +

    - #default_worker_optionsHash<Symbol, Object> + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker @@ -909,12 +981,13 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    -

    Returns the default worker options from Sidekiq

    +

    Attempt to constantize a string worker_class argument, always +failing back to the original argument when the constant can't be found

    @@ -927,7 +1000,7 @@

  • - (Hash<Symbol, Object>) + (Sidekiq::Worker) @@ -939,9 +1012,9 @@

  • -

    +

    - #sidekiq_worker_class?true, false + #job_method_defined?(method_sym) ⇒ true, false @@ -949,12 +1022,12 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    -

    Tests that the

    +

    Avoids duplicating worker_class.respond_to? in multiple places

    @@ -967,26 +1040,9 @@

  • - (true) - - - - — -

    if worker_class responds to get_sidekiq_options

    -
    - -
  • - -
  • - - - (false) - + (true, false) - — -

    if worker_class does not respond to get_sidekiq_options

    -
  • @@ -996,9 +1052,9 @@

    -

    +

    - #worker_classSidekiq::Worker + #job_optionsHash @@ -1006,12 +1062,12 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    -

    The Sidekiq::Worker implementation

    +

    Wraps #get_sidekiq_options to always work with a hash

    @@ -1024,50 +1080,13 @@

  • - (Sidekiq::Worker) + (Hash) -
  • - - - -

    -
    - -
    -

    - - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Attempt to constantize a string worker_class argument, always -failing back to the original argument when the constant can't be found

    - - -
    + — +

    of the worker class sidekiq options

    -
    - -

    Returns:

    -
    -

    +

    - #worker_method_defined?(method_sym) ⇒ true, false + #sidekiq_job_class?true, false @@ -1087,12 +1106,12 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    -

    Avoids duplicating worker_class.respond_to? in multiple places

    +

    Tests that the

    @@ -1105,52 +1124,25 @@

  • - (true, false) + (true) -
  • - - - -

    -
    - -
    -

    - - #worker_optionsHash - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Wraps #get_sidekiq_options to always work with a hash

    - - -
    + — +

    if job_class responds to get_sidekiq_options

    -
    - -

    Returns:

    -
      + +
    • - (Hash) + (false) — -

      of the worker class sidekiq options

      +

      if job_class does not respond to get_sidekiq_options

    • @@ -1165,9 +1157,9 @@

    diff --git a/doc/SidekiqUniqueJobs/LockType.html b/doc/SidekiqUniqueJobs/LockType.html new file mode 100644 index 000000000..81e798465 --- /dev/null +++ b/doc/SidekiqUniqueJobs/LockType.html @@ -0,0 +1,1008 @@ + + + + + + + Class: SidekiqUniqueJobs::LockType + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: SidekiqUniqueJobs::LockType + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    SidekiqWorkerMethods
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/lock_type.rb
    +
    + +
    + +

    Overview

    +
    +

    Calculates the lock type

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    + + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(item) ⇒ LockType + + + + + +

    +
    +

    Returns a new instance of LockType.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + item + + + (Hash) + + + + — +

      the Sidekiq job hash

      +
      + +
    • + +
    + + + + +

    Options Hash (item):

    +
      + +
    • + :lock + (Symbol, nil) + + + + + —

      the type of lock to use.

      +
      + +
    • + +
    • + :class + (String) + + + + + —

      the class of the sidekiq worker

      +
      + +
    • + +
    + + + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +31
    +
    +
    # File 'lib/sidekiq_unique_jobs/lock_type.rb', line 28
    +
    +def initialize(item)
    +  @item = item
    +  self.job_class = item[CLASS]
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #itemObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute item.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +23
    +24
    +25
    +
    +
    # File 'lib/sidekiq_unique_jobs/lock_type.rb', line 23
    +
    +def item
    +  @item
    +end
    +
    +
    + + + +
    +

    + + #job_classObject + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the value of attribute job_class.

    + + +
    +
    +
    + + +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .call(item) ⇒ Symbol, NilClass + + + + + +

    +
    +

    Computes lock type from job arguments, sidekiq_options.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Symbol) + + + + — +

      the lock type

      +
      + +
    • + +
    • + + + (NilClass) + + + + — +

      if no lock type is found.

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +
    +
    # File 'lib/sidekiq_unique_jobs/lock_type.rb', line 17
    +
    +def self.call(item)
    +  new(item).call
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #after_unlock_hookProc + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    The hook to call after a successful unlock

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Proc) + + + +
    • + +
    + +
    +
    + +
    +

    + + #callObject + + + + + +

    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/sidekiq_unique_jobs/lock_type.rb', line 33
    +
    +def call
    +  item[LOCK] || job_options[LOCK] || default_job_options[LOCK]
    +end
    +
    +
    + +
    +

    + + #default_job_optionsHash<Symbol, Object> + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the default worker options from Sidekiq

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash<Symbol, Object>) + + + +
    • + +
    + +
    +
    + +
    +

    + + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Attempt to constantize a string worker_class argument, always +failing back to the original argument when the constant can't be found

    + + +
    +
    +
    + +

    Returns:

    + + +
    +
    + +
    +

    + + #job_method_defined?(method_sym) ⇒ true, false + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Avoids duplicating worker_class.respond_to? in multiple places

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    +
    + +
    +

    + + #job_optionsHash + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Wraps #get_sidekiq_options to always work with a hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +

      of the worker class sidekiq options

      +
      + +
    • + +
    + +
    +
    + +
    +

    + + #sidekiq_job_class?true, false + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Tests that the

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true) + + + + — +

      if job_class responds to get_sidekiq_options

      +
      + +
    • + +
    • + + + (false) + + + + — +

      if job_class does not respond to get_sidekiq_options

      +
      + +
    • + +
    + +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/Locksmith.html b/doc/SidekiqUniqueJobs/Locksmith.html index 372badc3d..b27103261 100644 --- a/doc/SidekiqUniqueJobs/Locksmith.html +++ b/doc/SidekiqUniqueJobs/Locksmith.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Locksmith - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -170,6 +170,11 @@

    0.01
    +
    NETWORK_FACTOR = + +
    +
    0.04
    + @@ -715,7 +720,7 @@

  • - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -1019,16 +1024,16 @@

     
     
    -62
     63
     64
     65
     66
     67
    -68
    +68 +69

  • -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 62
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 63
     
     def initialize(item, redis_pool = nil)
       @item        = item
    @@ -1074,12 +1079,12 @@ 

     
     
    -47
     48
    -49
    +49 +50

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 47
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 48
     
     def config
       @config
    @@ -1116,12 +1121,12 @@ 

     
     
    -51
     52
    -53
    +53 +54

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 51
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 52
     
     def item
       @item
    @@ -1158,12 +1163,12 @@ 

     
     
    -43
     44
    -45
    +45 +46

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 43
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 44
     
     def job_id
       @job_id
    @@ -1200,12 +1205,12 @@ 

     
     
    -39
     40
    -41
    +41 +42

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 39
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 40
     
     def key
       @key
    @@ -1279,12 +1284,12 @@ 

     
     
    -171
    -172
    -173
    +175 +176 +177

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 171
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 175
     
     def ==(other)
       key == other.key && job_id == other.job_id
    @@ -1399,14 +1404,14 @@ 

     
     
    -74
     75
     76
     77
    -78
    +78 +79

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 74
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 75
     
     def delete
       return if config.pttl.positive?
    @@ -1443,12 +1448,12 @@ 

     
     
    -83
     84
    -85
    +85 +86

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 83
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 84
     
     def delete!
       call_script(:delete, key.to_a, [job_id, config.pttl, config.type, config.limit]).to_i.positive?
    @@ -1495,16 +1500,16 @@ 

     
     
    -101
     102
     103
     104
     105
     106
    -107
    +107 +108

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 101
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 102
     
     def execute(&block)
       raise SidekiqUniqueJobs::InvalidArgument, "#execute needs a block" unless block
    @@ -1549,12 +1554,12 @@ 

     
     
    -160
    -161
    -162
    +164 +165 +166

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 160
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 164
     
     def inspect
       to_s
    @@ -1606,17 +1611,17 @@ 

     
     
    -92
     93
     94
     95
     96
     97
     98
    -99
    +99 +100

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 92
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 93
     
     def lock(wait: nil)
       method_name = wait ? :primed_async : :primed_sync
    @@ -1694,14 +1699,14 @@ 

     
     
    -141
    -142
    -143
    -144
    -145
    +145 +146 +147 +148 +149

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 141
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 145
     
     def locked?(conn = nil)
       return taken?(conn) if conn
    @@ -2145,7 +2150,7 @@ 

    - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -2171,7 +2176,7 @@

  • - (Sidekiq::RedisConnection, ConnectionPool) + (Sidekiq::RedisConnection) @@ -2285,12 +2290,12 @@

     
     
    -153
    -154
    -155
    +157 +158 +159

  • -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 153
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 157
     
     def to_s
       "Locksmith##{object_id}(digest=#{key} job_id=#{job_id} locked=#{locked?})"
    @@ -2355,14 +2360,14 @@ 

     
     
    -115
     116
     117
     118
    -119
    +119 +120

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 115
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 116
     
     def unlock(conn = nil)
       return false unless locked?(conn)
    @@ -2429,20 +2434,26 @@ 

     
     
    -127
     128
     129
     130
     131
     132
    -133
    +133 +134 +135 +136 +137

    -
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 127
    +      
    # File 'lib/sidekiq_unique_jobs/locksmith.rb', line 128
     
     def unlock!(conn = nil)
       call_script(:unlock, key.to_a, argv, conn) do |unlocked_jid|
    -    reflect(:debug, :unlocked, item, unlocked_jid) if unlocked_jid == job_id
    +    if unlocked_jid == job_id
    +      reflect(:debug, :unlocked, item, unlocked_jid)
    +      reflect(:unlocked, item)
    +    end
     
         unlocked_jid
       end
    @@ -2541,9 +2552,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Logging.html b/doc/SidekiqUniqueJobs/Logging.html index aebdcfc8c..17fbcebad 100644 --- a/doc/SidekiqUniqueJobs/Logging.html +++ b/doc/SidekiqUniqueJobs/Logging.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Logging - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -457,23 +457,23 @@

     
     
    -107
    -108
    -109
    -110
    -111
    -112
    -113
    -114
    -115
    -116
     117
     118
     119
    -120
    +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 107
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 117
     
     def build_message(message_or_exception, item = nil)
       return nil if message_or_exception.nil?
    @@ -561,12 +561,16 @@ 

    33 34 35 -36

    +36 +37 +38
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 32
     
     def log_debug(message_or_exception = nil, item = nil, &block)
    +  return unless logging?
    +
       message = build_message(message_or_exception, item)
       logger.debug(message, &block)
       nil
    @@ -639,16 +643,20 @@ 

     
     
    -77
    -78
    -79
    -80
    -81
    +83 +84 +85 +86 +87 +88 +89

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 77
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 83
     
     def log_error(message_or_exception = nil, item = nil, &block)
    +  return unless logging?
    +
       message = build_message(message_or_exception, item)
       logger.error(message, &block)
       nil
    @@ -721,17 +729,21 @@ 

     
     
    -92
    -93
    -94
    -95
    -96
    -97
    +100 +101 +102 +103 +104 +105 +106 +107

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 92
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 100
     
     def log_fatal(message_or_exception = nil, item = nil, &block)
    +  return unless logging?
    +
       message = build_message(message_or_exception, item)
       logger.fatal(message, &block)
     
    @@ -805,16 +817,20 @@ 

     
     
    -47
    -48
     49
     50
    -51
    +51 +52 +53 +54 +55

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 47
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 49
     
     def log_info(message_or_exception = nil, item = nil, &block)
    +  return unless logging?
    +
       message = build_message(message_or_exception, item)
       logger.info(message, &block)
       nil
    @@ -887,16 +903,20 @@ 

     
     
    -62
    -63
    -64
    -65
    -66
    +66 +67 +68 +69 +70 +71 +72

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 62
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 66
     
     def log_warn(message_or_exception = nil, item = nil, &block)
    +  return unless logging?
    +
       message = build_message(message_or_exception, item)
       logger.warn(message, &block)
       nil
    @@ -1021,12 +1041,12 @@ 

     
     
    -156
    -157
    -158
    +166 +167 +168

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 156
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 166
     
     def logging_context
       raise NotImplementedError, "#{__method__} needs to be implemented in #{self.class}"
    @@ -1074,12 +1094,12 @@ 

     
     
    -146
    -147
    -148
    +156 +157 +158

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 146
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 156
     
     def with_configured_loggers_context(&block)
       logger_method.call(logging_context, &block)
    @@ -1131,16 +1151,16 @@ 

     
     
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    +140 +141 +142 +143 +144 +145 +146

    -
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 130
    +      
    # File 'lib/sidekiq_unique_jobs/logging.rb', line 140
     
     def with_logging_context
       with_configured_loggers_context do
    @@ -1159,9 +1179,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Logging/Middleware.html b/doc/SidekiqUniqueJobs/Logging/Middleware.html index daef8f1ed..6cb3614e7 100644 --- a/doc/SidekiqUniqueJobs/Logging/Middleware.html +++ b/doc/SidekiqUniqueJobs/Logging/Middleware.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Logging::Middleware - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -1046,9 +1046,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Middleware.html b/doc/SidekiqUniqueJobs/Middleware.html index 23c2e40bd..52d4b4f4c 100644 --- a/doc/SidekiqUniqueJobs/Middleware.html +++ b/doc/SidekiqUniqueJobs/Middleware.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Middleware - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -288,7 +288,7 @@

  • - #lock_type ⇒ Symbol + #lock_type ⇒ Symbol, NilClass @@ -997,10 +997,10 @@

    # File 'lib/sidekiq_unique_jobs/middleware.rb', line 31
     
     def call(worker_class, item, queue, redis_pool = nil)
    -  @worker_class = worker_class
    -  @item         = item
    -  @queue        = queue
    -  @redis_pool   = redis_pool
    +  @item       = item
    +  @queue      = queue
    +  @redis_pool = redis_pool
    +  self.job_class = worker_class
       return yield if unique_disabled?
     
       SidekiqUniqueJobs::Job.prepare(item) unless item[LOCK_DIGEST]
    @@ -1101,7 +1101,7 @@ 

    - #lock_typeSymbol + #lock_typeSymbol, NilClass @@ -1127,7 +1127,7 @@

  • - (Symbol) + (Symbol, NilClass) @@ -1807,9 +1807,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/Middleware/Client.html b/doc/SidekiqUniqueJobs/Middleware/Client.html index 71aa853d6..29993f1f0 100644 --- a/doc/SidekiqUniqueJobs/Middleware/Client.html +++ b/doc/SidekiqUniqueJobs/Middleware/Client.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Middleware::Client - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -89,7 +89,7 @@
    Includes:
    -
    SidekiqUniqueJobs::Middleware, Reflectable
    +
    Sidekiq::ClientMiddleware, SidekiqUniqueJobs::Middleware, Reflectable
    @@ -292,7 +292,7 @@

  • - #lock_type ⇒ Symbol + #lock_type ⇒ Symbol, NilClass @@ -725,6 +725,7 @@

    +

    Instance Attribute Details

    @@ -928,12 +929,12 @@

     
     
    -26
    -27
    -28
    +28 +29 +30

  • -
    # File 'lib/sidekiq_unique_jobs/middleware/client.rb', line 26
    +      
    # File 'lib/sidekiq_unique_jobs/middleware/client.rb', line 28
     
     def call(*, &block)
       lock(&block)
    @@ -1030,7 +1031,7 @@ 

    - #lock_typeSymbol + #lock_typeSymbol, NilClass @@ -1056,7 +1057,7 @@

  • - (Symbol) + (Symbol, NilClass) @@ -1797,9 +1798,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/Middleware/Server.html b/doc/SidekiqUniqueJobs/Middleware/Server.html index b12a43a04..1fc5d74cb 100644 --- a/doc/SidekiqUniqueJobs/Middleware/Server.html +++ b/doc/SidekiqUniqueJobs/Middleware/Server.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Middleware::Server - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -89,7 +89,7 @@
    Includes:
    -
    SidekiqUniqueJobs::Middleware
    +
    Sidekiq::ServerMiddleware, SidekiqUniqueJobs::Middleware
    @@ -292,7 +292,7 @@

  • - #lock_type ⇒ Symbol + #lock_type ⇒ Symbol, NilClass @@ -695,6 +695,7 @@

    +

    Instance Attribute Details

    @@ -897,12 +898,12 @@

     
     
    -24
    -25
    -26
    +26 +27 +28

  • -
    # File 'lib/sidekiq_unique_jobs/middleware/server.rb', line 24
    +      
    # File 'lib/sidekiq_unique_jobs/middleware/server.rb', line 26
     
     def call(*, &block)
       lock_instance.execute(&block)
    @@ -999,7 +1000,7 @@ 

    - #lock_typeSymbol + #lock_typeSymbol, NilClass @@ -1025,7 +1026,7 @@

  • - (Symbol) + (Symbol, NilClass) @@ -1705,9 +1706,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/NoBlockGiven.html b/doc/SidekiqUniqueJobs/NoBlockGiven.html index a8826c3c1..4ec6567a5 100644 --- a/doc/SidekiqUniqueJobs/NoBlockGiven.html +++ b/doc/SidekiqUniqueJobs/NoBlockGiven.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::NoBlockGiven - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -128,9 +128,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/NoSuchNotificationError.html b/doc/SidekiqUniqueJobs/NoSuchNotificationError.html index 5bb621570..fc53e1eaa 100644 --- a/doc/SidekiqUniqueJobs/NoSuchNotificationError.html +++ b/doc/SidekiqUniqueJobs/NoSuchNotificationError.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::NoSuchNotificationError - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -128,9 +128,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/Normalizer.html b/doc/SidekiqUniqueJobs/Normalizer.html index b21f40169..52bb58bc9 100644 --- a/doc/SidekiqUniqueJobs/Normalizer.html +++ b/doc/SidekiqUniqueJobs/Normalizer.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Normalizer - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -239,9 +239,9 @@

    diff --git a/doc/SidekiqUniqueJobs/NotUniqueWorker.html b/doc/SidekiqUniqueJobs/NotUniqueWorker.html index 66ae73dd8..e5d8ef0ec 100644 --- a/doc/SidekiqUniqueJobs/NotUniqueWorker.html +++ b/doc/SidekiqUniqueJobs/NotUniqueWorker.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::NotUniqueWorker - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -223,9 +223,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict.html b/doc/SidekiqUniqueJobs/OnConflict.html index 76a78cb34..e70ed2197 100644 --- a/doc/SidekiqUniqueJobs/OnConflict.html +++ b/doc/SidekiqUniqueJobs/OnConflict.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::OnConflict - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -342,9 +342,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict/Log.html b/doc/SidekiqUniqueJobs/OnConflict/Log.html index 53aa41039..e0c239591 100644 --- a/doc/SidekiqUniqueJobs/OnConflict/Log.html +++ b/doc/SidekiqUniqueJobs/OnConflict/Log.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::OnConflict::Log - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -1116,9 +1116,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict/NullStrategy.html b/doc/SidekiqUniqueJobs/OnConflict/NullStrategy.html index 1981fa61a..abd1dc7ea 100644 --- a/doc/SidekiqUniqueJobs/OnConflict/NullStrategy.html +++ b/doc/SidekiqUniqueJobs/OnConflict/NullStrategy.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::OnConflict::NullStrategy - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -247,9 +247,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict/Raise.html b/doc/SidekiqUniqueJobs/OnConflict/Raise.html index 427705d61..fc25c82a2 100644 --- a/doc/SidekiqUniqueJobs/OnConflict/Raise.html +++ b/doc/SidekiqUniqueJobs/OnConflict/Raise.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::OnConflict::Raise - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -248,9 +248,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict/Reject.html b/doc/SidekiqUniqueJobs/OnConflict/Reject.html index 0da80a6e2..31c0362b3 100644 --- a/doc/SidekiqUniqueJobs/OnConflict/Reject.html +++ b/doc/SidekiqUniqueJobs/OnConflict/Reject.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::OnConflict::Reject - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -189,52 +189,6 @@

    An instance of Sidekiq::Deadset.

    -

  • - - -
  • - - - #deadset_kill ⇒ void - - - - - - - - - - - private - - -

    Use Sidekiqs built in Sidekiq::DeadSet#kill to get rid of the job.

    -
    - -
  • - - -
  • - - - #deadset_kill? ⇒ true, false - - - - - - - - - - - private - - -

    Sidekiq version compatibility check.

    -
    -
  • @@ -327,29 +281,6 @@

    The Sidekiq job hash as JSON.

    - - - -
  • - - - #push_to_deadset ⇒ void - - - - - - - - - - - - - -

    Used for compatibility with older Sidekiq versions.

    -
    -
  • @@ -419,10 +350,10 @@

    def call log_info { "Adding dead #{item[CLASS]} job #{item[JID]}" } - if deadset_kill? - deadset_kill + if kill_with_options? + kill_job_with_options else - push_to_deadset + kill_job_without_options end end

    @@ -477,12 +408,12 @@

     
     
    -87
    -88
    -89
    +60 +61 +62

    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 87
    +      
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 60
     
     def deadset
       @deadset ||= Sidekiq::DeadSet.new
    @@ -490,120 +421,6 @@ 

    - - -
    -

    - - #deadset_killvoid - - - - - -

    -
    -

    - This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

    -

    This method returns an undefined value.

    Use Sidekiqs built in Sidekiq::DeadSet#kill - to get rid of the job

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -
    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 41
    -
    -def deadset_kill
    -  if kill_with_options?
    -    kill_job_with_options
    -  else
    -    kill_job_without_options
    -  end
    -end
    -
    -
    - -
    -

    - - #deadset_kill?true, false - - - - - -

    -
    -

    - This method is part of a private API. - You should avoid using this method if possible, as it may be removed or be changed in the future. -

    -

    Sidekiq version compatibility check

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (true, false) - - - - — -

      depending on if Sidekiq::Deadset responds to kill

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -29
    -30
    -31
    -
    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 29
    -
    -def deadset_kill?
    -  deadset.respond_to?(:kill)
    -end
    -
    @@ -635,12 +452,12 @@

     
     
    -77
    -78
    -79
    +50 +51 +52

    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 77
    +      
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 50
     
     def kill_job_with_options
       deadset.kill(payload, notify_failure: false)
    @@ -679,12 +496,12 @@ 

     
     
    -67
    -68
    -69
    +40 +41 +42

    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 67
    +      
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 40
     
     def kill_job_without_options
       deadset.kill(payload)
    @@ -753,12 +570,12 @@ 

     
     
    -57
    -58
    -59
    +30 +31 +32

    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 57
    +      
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 30
     
     def kill_with_options?
       Sidekiq::DeadSet.instance_method(:kill).arity > 1
    @@ -810,12 +627,12 @@ 

     
     
    -113
    -114
    -115
    +70 +71 +72

    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 113
    +      
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 70
     
     def payload
       @payload ||= dump_json(item)
    @@ -823,58 +640,6 @@ 

    - - -
    -

    - - #push_to_deadsetvoid - - - - - -

    -
    -

    This method returns an undefined value.

    Used for compatibility with older Sidekiq versions

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -97
    -98
    -99
    -100
    -101
    -102
    -103
    -104
    -105
    -
    -
    # File 'lib/sidekiq_unique_jobs/on_conflict/reject.rb', line 97
    -
    -def push_to_deadset
    -  redis do |conn|
    -    conn.multi do
    -      conn.zadd("dead", now_f, payload)
    -      conn.zremrangebyscore("dead", "-inf", now_f - Sidekiq::DeadSet.timeout)
    -      conn.zremrangebyrank("dead", 0, -Sidekiq::DeadSet.max_jobs)
    -    end
    -  end
    -end
    -
    @@ -882,9 +647,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict/Replace.html b/doc/SidekiqUniqueJobs/OnConflict/Replace.html index d65390fc8..74ee1172e 100644 --- a/doc/SidekiqUniqueJobs/OnConflict/Replace.html +++ b/doc/SidekiqUniqueJobs/OnConflict/Replace.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::OnConflict::Replace - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -689,7 +689,7 @@

    # File 'lib/sidekiq_unique_jobs/on_conflict/replace.rb', line 67
     
     def delete_lock
    -  digests.delete_by_digest(lock_digest)
    +  digests.delete_by_digest(lock_digest, runtime: false)
     end
    @@ -758,9 +758,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict/Reschedule.html b/doc/SidekiqUniqueJobs/OnConflict/Reschedule.html index 51e213bff..e1e49fe3f 100644 --- a/doc/SidekiqUniqueJobs/OnConflict/Reschedule.html +++ b/doc/SidekiqUniqueJobs/OnConflict/Reschedule.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::OnConflict::Reschedule - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -135,6 +135,42 @@

    Overview

    +

    Instance Attribute Summary collapse

    + + @@ -228,7 +264,7 @@

  • - #default_worker_options ⇒ Hash<Symbol, Object> + #default_job_options ⇒ Hash<Symbol, Object> @@ -236,7 +272,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -281,7 +317,7 @@

  • - #log_debug(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker @@ -289,7 +325,7 @@

    included - from Logging + from SidekiqWorkerMethods @@ -300,7 +336,7 @@

    -

    Logs a message at debug level.

    +

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

  • @@ -309,7 +345,7 @@

  • - #log_error(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #job_method_defined?(method_sym) ⇒ true, false @@ -317,7 +353,7 @@

    included - from Logging + from SidekiqWorkerMethods @@ -328,7 +364,7 @@

    -

    Logs a message at error level.

    +

    Avoids duplicating worker_class.respond_to? in multiple places.

  • @@ -337,7 +373,7 @@

  • - #log_fatal(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #job_options ⇒ Hash @@ -345,7 +381,7 @@

    included - from Logging + from SidekiqWorkerMethods @@ -356,7 +392,7 @@

    -

    Logs a message at fatal level.

    +

    Wraps #get_sidekiq_options to always work with a hash.

  • @@ -365,7 +401,7 @@

  • - #log_info(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #log_debug(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -373,7 +409,7 @@

    included - from Logging + from Logging @@ -384,7 +420,7 @@

    -

    Logs a message at info level.

    +

    Logs a message at debug level.

  • @@ -393,7 +429,7 @@

  • - #log_warn(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void + #log_error(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -401,7 +437,7 @@

    included - from Logging + from Logging @@ -412,7 +448,7 @@

    -

    Logs a message at warn level.

    +

    Logs a message at error level.

  • @@ -421,7 +457,7 @@

  • - #logger ⇒ Logger + #log_fatal(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -429,7 +465,7 @@

    included - from Logging + from Logging @@ -440,7 +476,7 @@

    -

    A convenience method for using the configured gem logger.

    +

    Logs a message at fatal level.

  • @@ -449,7 +485,7 @@

  • - #logging_context ⇒ Hash + #log_info(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -457,7 +493,7 @@

    included - from Logging + from Logging @@ -468,7 +504,7 @@

    -

    Setup some variables to add to each log line.

    +

    Logs a message at info level.

  • @@ -477,7 +513,7 @@

  • - #reflect(reflection, *args) ⇒ void + #log_warn(message_or_exception = nil, item = nil) {|String, Exception| ... } ⇒ void @@ -485,7 +521,7 @@

    included - from Reflectable + from Logging @@ -496,7 +532,7 @@

    -

    Reflects on specific event.

    +

    Logs a message at warn level.

  • @@ -505,7 +541,7 @@

  • - #sidekiq_worker_class? ⇒ true, false + #logger ⇒ Logger @@ -513,7 +549,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -524,7 +560,7 @@

    -

    Tests that the.

    +

    A convenience method for using the configured gem logger.

  • @@ -533,7 +569,7 @@

  • - #with_configured_loggers_context { ... } ⇒ void + #logging_context ⇒ Hash @@ -541,7 +577,7 @@

    included - from Logging + from Logging @@ -552,7 +588,7 @@

    -

    Attempt to setup context aware logging for the given logger.

    +

    Setup some variables to add to each log line.

  • @@ -561,7 +597,7 @@

  • - #with_logging_context ⇒ void + #reflect(reflection, *args) ⇒ void @@ -569,7 +605,7 @@

    included - from Logging + from Reflectable @@ -580,7 +616,7 @@

    -

    Wraps the middleware logic with context aware logging.

    +

    Reflects on specific event.

  • @@ -589,17 +625,12 @@

  • - #worker_class ⇒ Sidekiq::Worker + #schedule_in ⇒ Object - - included - from SidekiqWorkerMethods - - @@ -608,8 +639,7 @@

    -

    The Sidekiq::Worker implementation.

    -
    +

  • @@ -617,7 +647,7 @@

  • - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #sidekiq_job_class? ⇒ true, false @@ -625,7 +655,7 @@

    included - from SidekiqWorkerMethods + from SidekiqWorkerMethods @@ -636,7 +666,7 @@

    -

    Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

    +

    Tests that the.

  • @@ -645,7 +675,7 @@

  • - #worker_method_defined?(method_sym) ⇒ true, false + #with_configured_loggers_context { ... } ⇒ void @@ -653,7 +683,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -664,7 +694,7 @@

    -

    Avoids duplicating worker_class.respond_to? in multiple places.

    +

    Attempt to setup context aware logging for the given logger.

  • @@ -673,7 +703,7 @@

  • - #worker_options ⇒ Hash + #with_logging_context ⇒ void @@ -681,7 +711,7 @@

    included - from SidekiqWorkerMethods + from Logging @@ -692,7 +722,7 @@

    -

    Wraps #get_sidekiq_options to always work with a hash.

    +

    Wraps the middleware logic with context aware logging.

  • @@ -772,7 +802,7 @@

    def initialize(item, redis_pool = nil) super(item, redis_pool) - @worker_class = item[CLASS] + self.job_class = item[CLASS] end

  • @@ -781,6 +811,40 @@

    +
    +

    Instance Attribute Details

    + + + +
    +

    + + #job_classObject + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Returns the value of attribute job_class.

    + + +
    +
    +
    + + +
    +
    + +
    +

    Instance Method Details

    @@ -948,8 +1012,8 @@

    # File 'lib/sidekiq_unique_jobs/on_conflict/reschedule.rb', line 22
     
     def call
    -  if sidekiq_worker_class?
    -    if worker_class.perform_in(5, *item[ARGS])
    +  if sidekiq_job_class?
    +    if job_class.set(queue: item["queue"].to_sym).perform_in(schedule_in, *item[ARGS])
           reflect(:rescheduled, item)
         else
           reflect(:reschedule_failed, item)
    @@ -964,9 +1028,9 @@ 

    -

    +

    - #default_worker_optionsHash<Symbol, Object> + #default_job_optionsHash<Symbol, Object> @@ -974,7 +1038,7 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    @@ -1000,6 +1064,131 @@

    +

    +
    + +
    +

    + + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Attempt to constantize a string worker_class argument, always +failing back to the original argument when the constant can't be found

    + + +
    +
    +
    + +

    Returns:

    + + +
    +
    + +
    +

    + + #job_method_defined?(method_sym) ⇒ true, false + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Avoids duplicating worker_class.respond_to? in multiple places

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (true, false) + + + +
    • + +
    + +
    +
    + +
    +

    + + #job_optionsHash + + + + + + + Originally defined in module + SidekiqWorkerMethods + + +

    +
    +

    Wraps #get_sidekiq_options to always work with a hash

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + + — +

      of the worker class sidekiq options

      +
      + +
    • + +
    +
    @@ -1494,9 +1683,39 @@

    -

    +

    + + #schedule_inObject - #sidekiq_worker_class?true, false + + + + +

    + + + + +
    +
    +
    +
    +34
    +35
    +36
    +
    +
    # File 'lib/sidekiq_unique_jobs/on_conflict/reschedule.rb', line 34
    +
    +def schedule_in
    +  job_class.get_sidekiq_options["schedule_in"] || 5
    +end
    +
    +
    + +
    +

    + + #sidekiq_job_class?true, false @@ -1504,7 +1723,7 @@

    Originally defined in module - SidekiqWorkerMethods + SidekiqWorkerMethods

    @@ -1527,7 +1746,7 @@

    — -

    if worker_class responds to get_sidekiq_options

    +

    if job_class responds to get_sidekiq_options

    @@ -1540,7 +1759,7 @@

    — -

    if worker_class does not respond to get_sidekiq_options

    +

    if job_class does not respond to get_sidekiq_options

    @@ -1631,171 +1850,6 @@

    -

    -

    - -
    -

    - - #worker_classSidekiq::Worker - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    The Sidekiq::Worker implementation

    - - -
    -
    -
    - -

    Returns:

    - - -
    -
    - -
    -

    - - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Attempt to constantize a string worker_class argument, always -failing back to the original argument when the constant can't be found

    - - -
    -
    -
    - -

    Returns:

    - - -
    -
    - -
    -

    - - #worker_method_defined?(method_sym) ⇒ true, false - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Avoids duplicating worker_class.respond_to? in multiple places

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (true, false) - - - -
    • - -
    - -
    -
    - -
    -

    - - #worker_optionsHash - - - - - - - Originally defined in module - SidekiqWorkerMethods - - -

    -
    -

    Wraps #get_sidekiq_options to always work with a hash

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Hash) - - - - — -

      of the worker class sidekiq options

      -
      - -
    • - -
    -
    @@ -1804,9 +1858,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OnConflict/Strategy.html b/doc/SidekiqUniqueJobs/OnConflict/Strategy.html index e1413c86d..cb2bd375d 100644 --- a/doc/SidekiqUniqueJobs/OnConflict/Strategy.html +++ b/doc/SidekiqUniqueJobs/OnConflict/Strategy.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::OnConflict::Strategy - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -1477,9 +1477,9 @@

    diff --git a/doc/SidekiqUniqueJobs/OptionsWithFallback.html b/doc/SidekiqUniqueJobs/OptionsWithFallback.html index 48c993d54..f0bcded53 100644 --- a/doc/SidekiqUniqueJobs/OptionsWithFallback.html +++ b/doc/SidekiqUniqueJobs/OptionsWithFallback.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::OptionsWithFallback - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -97,7 +97,7 @@

    Overview

    1. item (required)
    2. options (can be nil)
    3. -
    4. worker_class (required, can be anything)
    5. +
    6. job_class (required, can be anything)
    @@ -185,7 +185,7 @@

  • - #lock_type ⇒ Symbol + #lock_type ⇒ Symbol, NilClass @@ -423,7 +423,7 @@

    - #lock_typeSymbol + #lock_typeSymbol, NilClass @@ -444,7 +444,7 @@

  • - (Symbol) + (Symbol, NilClass) @@ -564,8 +564,8 @@

    def options @options ||= begin - opts = default_worker_options.dup - opts.merge!(worker_options) if sidekiq_worker_class? + opts = default_job_options.dup + opts.merge!(job_options) if sidekiq_job_class? (opts || {}).stringify_keys end end

  • @@ -689,9 +689,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Orphans.html b/doc/SidekiqUniqueJobs/Orphans.html index 3387d7588..3232a0742 100644 --- a/doc/SidekiqUniqueJobs/Orphans.html +++ b/doc/SidekiqUniqueJobs/Orphans.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Orphans - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -141,9 +141,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/Orphans/LuaReaper.html b/doc/SidekiqUniqueJobs/Orphans/LuaReaper.html index 04dcf11eb..9a69c2463 100644 --- a/doc/SidekiqUniqueJobs/Orphans/LuaReaper.html +++ b/doc/SidekiqUniqueJobs/Orphans/LuaReaper.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Orphans::LuaReaper - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -254,7 +254,7 @@

    call_script( :reap_orphans, conn, - keys: [DIGESTS, SCHEDULE, RETRY, PROCESSES], + keys: [DIGESTS, EXPIRING_DIGESTS, SCHEDULE, RETRY, PROCESSES], argv: [reaper_count, (Time.now - reaper_timeout).to_f], ) end

    @@ -268,9 +268,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Orphans/Manager.html b/doc/SidekiqUniqueJobs/Orphans/Manager.html index cc92d6a88..d010909e8 100644 --- a/doc/SidekiqUniqueJobs/Orphans/Manager.html +++ b/doc/SidekiqUniqueJobs/Orphans/Manager.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Orphans::Manager - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -284,7 +284,7 @@

    -

    Reaper interval with a little drift Redis isn't exact enough so to give a little bufffer, we add a tiny value to the reaper interval.

    +

    Reaper interval with a little drift Redis isn't exact enough so to give a little buffer, we add a tiny value to the reaper interval.

    @@ -375,28 +375,6 @@

    -
    - - - - -
  • - - - .reaper_timeout ⇒ Object - - - - - - - - - - - - -
  • @@ -679,12 +657,12 @@

     
     
    -243
    -244
    -245
    +237 +238 +239

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 243
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 237
     
     def current_timestamp
       Time.now.to_i
    @@ -732,22 +710,22 @@ 

     
     
    -82
    -83
    -84
     85
     86
     87
     88
     89
     90
    -91
    +91 +92 +93 +94

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 82
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 85
     
     def default_task
    -  SidekiqUniqueJobs::TimerTask.new(timer_task_options) do
    +  SidekiqUniqueJobs::TimerTask.new(timer_task_options) do
         with_logging_context do
           redis do |conn|
             refresh_reaper_mutex
    @@ -806,12 +784,12 @@ 

     
     
    -182
    -183
    -184
    +176 +177 +178

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 182
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 176
     
     def disabled?
       !enabled?
    @@ -833,7 +811,7 @@ 

    Reaper interval with a little drift - Redis isn't exact enough so to give a little bufffer, + Redis isn't exact enough so to give a little buffer, we add a tiny value to the reaper interval.

    @@ -865,12 +843,12 @@

     
     
    -233
    -234
    -235
    +227 +228 +229

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 233
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 227
     
     def drift_reaper_interval
       reaper_interval + (reaper_interval * DRIFT_FACTOR).to_i
    @@ -918,12 +896,12 @@ 

     
     
    -191
    -192
    -193
    +185 +186 +187

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 191
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 185
     
     def enabled?
       REAPERS.include?(reaper)
    @@ -988,16 +966,16 @@ 

     
     
    -144
    -145
    -146
    -147
    -148
    -149
    -150
    +138 +139 +140 +141 +142 +143 +144

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 144
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 138
     
     def logging_context
       if logger_context_hash?
    @@ -1042,12 +1020,12 @@ 

     
     
    -119
     120
    -121
    +121 +122

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 119
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 120
     
     def reaper
       SidekiqUniqueJobs.config.reaper
    @@ -1088,12 +1066,12 @@ 

     
     
    -126
     127
    -128
    +128 +129

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 126
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 127
     
     def reaper_interval
       SidekiqUniqueJobs.config.reaper_interval
    @@ -1101,52 +1079,6 @@ 

    - - -
    -

    - - .reaper_timeoutObject - - - - - -

    -
    - - -
    -
    -
    - - -

    See Also:

    -
      - -
    • Config#reaper_timeout
    • - -
    - -
    - - - - -
    -
    -
    -
    -133
    -134
    -135
    -
    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 133
    -
    -def reaper_timeout
    -  SidekiqUniqueJobs.config.reaper_timeout
    -end
    -
    @@ -1174,15 +1106,15 @@

     
     
    -211
    -212
    -213
    +205 +206 +207

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 211
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 205
     
     def refresh_reaper_mutex
    -  redis { |conn| conn.set(UNIQUE_REAPER, current_timestamp, ex: drift_reaper_interval) }
    +  redis { |conn| conn.set(UNIQUE_REAPER, current_timestamp, "ex", drift_reaper_interval) }
     end
    @@ -1214,15 +1146,15 @@

     
     
    -201
    -202
    -203
    +195 +196 +197

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 201
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 195
     
     def register_reaper_process
    -  redis { |conn| conn.set(UNIQUE_REAPER, current_timestamp, nx: true, ex: drift_reaper_interval) }
    +  redis { |conn| conn.set(UNIQUE_REAPER, current_timestamp, "nx", "ex", drift_reaper_interval) }
     end
    @@ -1267,14 +1199,14 @@

     
     
    -158
    -159
    -160
    -161
    -162
    +152 +153 +154 +155 +156

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 158
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 152
     
     def registered?
       redis do |conn|
    @@ -1328,8 +1260,6 @@ 

     
     
    -33
    -34
     35
     36
     37
    @@ -1342,10 +1272,13 @@ 

    44 45 46 -47

    +47 +48 +49 +50

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 33
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 35
     
     def start(test_task = nil) # rubocop:disable
       return if disabled?
    @@ -1354,12 +1287,13 @@ 

    self.task = test_task || default_task with_logging_context do - register_reaper_process - log_info("Starting Reaper") + if register_reaper_process + log_info("Starting Reaper") - task.add_observer(Observer.new) - task.execute - task + task.add_observer(Observer.new) + task.execute + task + end end end

    @@ -1405,19 +1339,19 @@

     
     
    -55
    -56
    -57
     58
     59
     60
     61
     62
     63
    -64
    +64 +65 +66 +67

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 55
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 58
     
     def stop
       return if disabled?
    @@ -1476,16 +1410,16 @@ 

     
     
    -72
    -73
    -74
    +75 +76 +77

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 72
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 75
     
     def task
    -  @task ||= default_task
    -end
    + @task ||= default_task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod +end
    @@ -1535,16 +1469,16 @@

     
     
    -100
    -101
    -102
    +103 +104 +105

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 100
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 103
     
     def task=(task)
    -  @task = task
    -end
    + @task = task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod +end
    @@ -1588,19 +1522,15 @@

     
     
    -110
    -111
    -112
     113
    -114
    +114 +115

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 110
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 113
     
     def timer_task_options
    -  { run_now: true,
    -    execution_interval: reaper_interval,
    -    timeout_interval: reaper_timeout }
    +  { run_now: true, execution_interval: reaper_interval }
     end
    @@ -1632,12 +1562,12 @@

     
     
    -221
    -222
    -223
    +215 +216 +217

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 221
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 215
     
     def unregister_reaper_process
       redis { |conn| conn.del(UNIQUE_REAPER) }
    @@ -1692,12 +1622,12 @@ 

     
     
    -171
    -172
    -173
    +165 +166 +167

    -
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 171
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 165
     
     def unregistered?
       !registered?
    @@ -1712,9 +1642,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Orphans/NullReaper.html b/doc/SidekiqUniqueJobs/Orphans/NullReaper.html index 025d77b60..5efe14698 100644 --- a/doc/SidekiqUniqueJobs/Orphans/NullReaper.html +++ b/doc/SidekiqUniqueJobs/Orphans/NullReaper.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Orphans::NullReaper - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -258,9 +258,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Orphans/Observer.html b/doc/SidekiqUniqueJobs/Orphans/Observer.html index a56cc3c1d..fb9b52222 100644 --- a/doc/SidekiqUniqueJobs/Orphans/Observer.html +++ b/doc/SidekiqUniqueJobs/Orphans/Observer.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Orphans::Observer - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -1177,9 +1177,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Orphans/Reaper.html b/doc/SidekiqUniqueJobs/Orphans/Reaper.html index d6b67d7de..c767f822a 100644 --- a/doc/SidekiqUniqueJobs/Orphans/Reaper.html +++ b/doc/SidekiqUniqueJobs/Orphans/Reaper.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Orphans::Reaper - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -636,7 +636,7 @@

  • - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -1708,7 +1708,7 @@

    - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -1734,7 +1734,7 @@

  • - (Sidekiq::RedisConnection, ConnectionPool) + (Sidekiq::RedisConnection) @@ -1838,9 +1838,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html b/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html index 129643b44..afdbc60fc 100644 --- a/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html +++ b/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Orphans::ReaperResurrector - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -1340,7 +1340,7 @@

    # File 'lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb', line 43
     
     def task
    -  SidekiqUniqueJobs::TimerTask.new(timer_task_options) do
    +  SidekiqUniqueJobs::TimerTask.new(timer_task_options) do
         with_logging_context do
           restart_if_dead
         end
    @@ -1411,9 +1411,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Orphans/RubyReaper.html b/doc/SidekiqUniqueJobs/Orphans/RubyReaper.html index ec22ec36e..116d75dc9 100644 --- a/doc/SidekiqUniqueJobs/Orphans/RubyReaper.html +++ b/doc/SidekiqUniqueJobs/Orphans/RubyReaper.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Orphans::RubyReaper - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -89,6 +89,11 @@ +
    +
    Includes:
    +
    Timing
    +
    + @@ -112,6 +117,8 @@

    Overview

    Class DeleteOrphans provides deletion of orphaned digests

    +

    rubocop:disable Metrics/ClassLength

    +
    @@ -174,6 +181,38 @@

    ":RUN"
    +
    MAX_QUEUE_LENGTH = +
    +
    +

    Returns the maximum combined length of sidekiq queues for running the reaper.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +

      the maximum combined length of sidekiq queues for running the reaper

      +
      + +
    • + +
    + +
    +
    +
    1000
    + @@ -264,6 +303,90 @@

    Instance Attribute Summary collaps

    Returns the value of attribute scheduled.

    +

  • + + +
  • + + + #start_source ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute start_source.

    +
    + +
  • + + +
  • + + + #start_time ⇒ Integer + + + + + + + + + readonly + + + + + + + + + +

    The clock stamp this execution started represented as integer (used for redis compatibility as it is more accurate than time).

    +
    + +
  • + + +
  • + + + #timeout_ms ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute timeout_ms.

    +
    +
  • @@ -366,6 +489,28 @@

    +
    + + + + +
  • + + + #elapsed_ms ⇒ Object + + + + + + + + + + + + +
  • @@ -414,6 +559,28 @@

    rubocop:disable Metrics/MethodLength.

    + + + +
  • + + + #expired_digests ⇒ Object + + + + + + + + + + + + + +
    +
  • @@ -530,6 +697,29 @@

    Loops through all the redis queues and yields them one by one.

    + + + +
  • + + + #queues_very_full? ⇒ Boolean + + + + + + + + + + + + + +

    If sidekiq queues are very full, it becomes highly inefficient for the reaper because it must check every queued job to verify a digest is safe to delete The reaper checks queued jobs in batches of 50, adding 2 reads per digest With a queue length of 1,000 jobs, that's over 20 extra reads per digest.

    +
    +
  • @@ -576,6 +766,28 @@

    Checks if the digest exists in the Sidekiq::ScheduledSet.

    + + + +
  • + + + #timeout? ⇒ Boolean + + + + + + + + + + + + + +
    +
  • @@ -592,6 +804,8 @@

    + +

    Constructor Details

    @@ -639,21 +853,27 @@

     
     
    -34
    -35
    -36
    -37
    -38
    -39
    +56 +57 +58 +59 +60 +61 +62 +63 +64

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 34
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 56
     
     def initialize(conn)
       super(conn)
    -  @digests   = SidekiqUniqueJobs::Digests.new
    -  @scheduled = Redis::SortedSet.new(SCHEDULE)
    -  @retried   = Redis::SortedSet.new(RETRY)
    +  @digests      = SidekiqUniqueJobs::Digests.new
    +  @scheduled    = Redis::SortedSet.new(SCHEDULE)
    +  @retried      = Redis::SortedSet.new(RETRY)
    +  @start_time   = Time.now
    +  @start_source = time_source.call
    +  @timeout_ms   = SidekiqUniqueJobs.config.reaper_timeout * 1000
     end
    @@ -692,12 +912,12 @@

     
     
    -19
    -20
    -21
    +25 +26 +27

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 19
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 25
     
     def digests
       @digests
    @@ -710,9 +930,135 @@ 

    -

    +

    + + #retriedObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute retried.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 33
    +
    +def retried
    +  @retried
    +end
    +
    +
    + + + +
    +

    + + #scheduledObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute scheduled.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +29
    +30
    +31
    +
    +
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 29
    +
    +def scheduled
    +  @scheduled
    +end
    +
    +
    + + + +
    +

    + + #start_sourceObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute start_source.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +44
    +45
    +46
    +
    +
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 44
    +
    +def start_source
    +  @start_source
    +end
    +
    +
    + + + +
    +

    - #retriedObject (readonly) + #start_timeInteger (readonly) @@ -720,13 +1066,32 @@

    -

    Returns the value of attribute retried.

    +

    Returns The clock stamp this execution started represented as integer +(used for redis compatibility as it is more accurate than time).

    +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +

      The clock stamp this execution started represented as integer +(used for redis compatibility as it is more accurate than time)

      +
      + +
    • + +
    @@ -734,15 +1099,15 @@

     
     
    -27
    -28
    -29
    +38 +39 +40

    @@ -752,9 +1117,9 @@

    -

    +

    - #scheduledObject (readonly) + #timeout_msObject (readonly) @@ -762,7 +1127,7 @@

    -

    Returns the value of attribute scheduled.

    +

    Returns the value of attribute timeout_ms.

    @@ -776,15 +1141,15 @@

     
     
    -23
    -24
    -25
    +49 +50 +51

    @@ -836,56 +1201,56 @@

     
     
    -123
    -124
    -125
    -126
    -127
    -128
    -129
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    -137
    -138
    -139
    -140
    -141
    -142
    -143
    -144
    -145
    -146
    -147
    -148
    -149
    -150
    -151
    -152
    -153
    -154
    +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212

    @@ -1098,12 +1469,12 @@

     
     
    -162
    -163
    -164
    +220 +221 +222

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 27
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 38
     
    -def retried
    -  @retried
    +def start_time
    +  @start_time
     end
    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 23
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 49
     
    -def scheduled
    -  @scheduled
    +def timeout_ms
    +  @timeout_ms
     end
    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 123
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 181
     
     def active?(digest) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
       Sidekiq.redis do |conn|
    -    procs = conn.sscan_each("processes").to_a
    +    procs = conn.sscan("processes").to_a
         return false if procs.empty?
     
         procs.sort.each do |key|
    -      valid, workers = conn.pipelined do
    +      valid, workers = conn.pipelined do |pipeline|
             # TODO: Remove the if statement in the future
    -        if conn.respond_to?(:exists?)
    -          conn.exists?(key)
    +        if pipeline.respond_to?(:exists?)
    +          pipeline.exists?(key)
             else
    -          conn.exists(key)
    +          pipeline.exists(key)
             end
    -        conn.hgetall("#{key}:workers")
    +        pipeline.hgetall("#{key}:work")
           end
     
           next unless valid
    @@ -989,12 +1354,12 @@ 

     
     
    -78
    -79
    -80
    +136 +137 +138

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 78
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 136
     
     def belongs_to_job?(digest)
       scheduled?(digest) || retried?(digest) || enqueued?(digest) || active?(digest)
    @@ -1046,14 +1411,20 @@ 

     
     
    -47
    -48
    -49
    +72 +73 +74 +75 +76 +77

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 47
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 72
     
     def call
    +  return if queues_very_full?
    +
    +  BatchDelete.call(expired_digests, conn)
       BatchDelete.call(orphans, conn)
     end
    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 162
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 220
     
     def considered_active?(time_f)
       (Time.now - reaper_timeout).to_f < time_f
    @@ -1111,6 +1482,36 @@ 

    +
    + +
    +

    + + #elapsed_msObject + + + + + +

    + + + + +
    +
    +
    +
    +120
    +121
    +122
    +
    +
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 120
    +
    +def elapsed_ms
    +  time_source.call - start_source
    +end
    +
    @@ -1174,20 +1575,20 @@

     
     
    -111
    -112
    -113
    -114
    -115
    -116
    -117
    -118
    -119
    -120
    -121
    +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 111
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 169
     
     def enqueued?(digest)
       Sidekiq.redis do |conn|
    @@ -1230,29 +1631,33 @@ 

     
     
    -179
    -180
    -181
    -182
    -183
    -184
    -185
    -186
    -187
    -188
    -189
    -190
    -191
    -192
    -193
    -194
    -195
    -196
    -197
    -198
    +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 179
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 237
     
     def entries(conn, queue, &block) # rubocop:disable Metrics/MethodLength
       queue_key    = "queue:#{queue}"
    @@ -1263,6 +1668,7 @@ 

    loop do range_start = (page * page_size) - deleted_size + range_end = range_start + page_size - 1 entries = conn.lrange(queue_key, range_start, range_end) page += 1 @@ -1272,11 +1678,48 @@

    entries.each(&block) deleted_size = initial_size - conn.llen(queue_key) + + # The queue is growing, not shrinking, just keep looping + deleted_size = 0 if deleted_size.negative? end end

    + + +
    +

    + + #expired_digestsObject + + + + + +

    + + + + +
    +
    +
    +
    +79
    +80
    +81
    +82
    +83
    +
    +
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 79
    +
    +def expired_digests
    +  max_score = (start_time - reaper_timeout).to_f
    +
    +  conn.zrange(EXPIRING_DIGESTS, 0, max_score, "byscore")
    +end
    +
    @@ -1368,15 +1811,15 @@

     
     
    -210
    -211
    -212
    +288 +289 +290

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 210
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 288
     
     def in_sorted_set?(key, digest)
    -  conn.zscan_each(key, match: "*#{digest}*", count: 1).to_a.any?
    +  conn.zscan(key, match: "*#{digest}*", count: 1).to_a.any?
     end
    @@ -1420,14 +1863,14 @@

     
     
    -156
    -157
    -158
    -159
    -160
    +214 +215 +216 +217 +218

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 156
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 214
     
     def match?(key_one, key_two)
       return false if key_one.nil? || key_two.nil?
    @@ -1481,25 +1924,57 @@ 

     
     
    -57
    -58
    -59
    -60
    -61
    -62
    -63
    -64
    +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 57
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 91
    +
    +def orphans # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
    +  page = 0
    +  per = reaper_count * 2
    +  orphans = []
    +  results = conn.zrange(digests.key, page * per, (page + 1) * per)
     
    -def orphans
    -  conn.zrevrange(digests.key, 0, -1).each_with_object([]) do |digest, memo|
    -    next if belongs_to_job?(digest)
    +  while results.size.positive?
    +    results.each do |digest|
    +      break if timeout?
    +      next if belongs_to_job?(digest)
     
    -    memo << digest
    -    break if memo.size >= reaper_count
    +      orphans << digest
    +      break if orphans.size >= reaper_count
    +    end
    +
    +    break if timeout?
    +    break if orphans.size >= reaper_count
    +
    +    page += 1
    +    results = conn.zrange(digests.key, page * per, (page + 1) * per)
       end
    +
    +  orphans
     end
    @@ -1567,15 +2042,87 @@

     
     
    -175
    -176
    -177
    +233 +234 +235

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 175
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 233
     
     def queues(conn, &block)
    -  conn.sscan_each("queues", &block)
    +  conn.sscan("queues").each(&block)
    +end
    + + + + + +
    +

    + + #queues_very_full?Boolean + + + + + +

    +
    +

    If sidekiq queues are very full, it becomes highly inefficient for the reaper +because it must check every queued job to verify a digest is safe to delete +The reaper checks queued jobs in batches of 50, adding 2 reads per digest +With a queue length of 1,000 jobs, that's over 20 extra reads per digest.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + @@ -1643,12 +2190,12 @@

     
     
    -100
    -101
    -102
    +158 +159 +160

    +
    +
    +
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +274
    +275
    +276
    +
    +
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 266
    +
    +def queues_very_full?
    +  total_queue_size = 0
    +  Sidekiq.redis do |conn|
    +    queues(conn) do |queue|
    +      total_queue_size += conn.llen("queue:#{queue}")
    +
    +      return true if total_queue_size > MAX_QUEUE_LENGTH
    +    end
    +  end
    +  false
     end
    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 100
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 158
     
     def retried?(digest)
       in_sorted_set?(RETRY, digest)
    @@ -1719,12 +2266,12 @@ 

     
     
    -89
    -90
    -91
    +147 +148 +149

    -
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 89
    +      
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 147
     
     def scheduled?(digest)
       in_sorted_set?(SCHEDULE, digest)
    @@ -1732,6 +2279,58 @@ 

    +
    + +
    +

    + + #timeout?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +116
    +117
    +118
    +
    +
    # File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 116
    +
    +def timeout?
    +  elapsed_ms >= timeout_ms
    +end
    +
    @@ -1739,9 +2338,9 @@

    diff --git a/doc/SidekiqUniqueJobs/RSpec.html b/doc/SidekiqUniqueJobs/RSpec.html index b1b4bb08e..ca84a2aec 100644 --- a/doc/SidekiqUniqueJobs/RSpec.html +++ b/doc/SidekiqUniqueJobs/RSpec.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::RSpec - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -132,9 +132,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/RSpec/Matchers.html b/doc/SidekiqUniqueJobs/RSpec/Matchers.html index 32e5a8f0a..138e66dac 100644 --- a/doc/SidekiqUniqueJobs/RSpec/Matchers.html +++ b/doc/SidekiqUniqueJobs/RSpec/Matchers.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::RSpec::Matchers - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -229,9 +229,9 @@

    diff --git a/doc/SidekiqUniqueJobs/RSpec/Matchers/HaveValidSidekiqOptions.html b/doc/SidekiqUniqueJobs/RSpec/Matchers/HaveValidSidekiqOptions.html index 90e5a7242..5086b0ecf 100644 --- a/doc/SidekiqUniqueJobs/RSpec/Matchers/HaveValidSidekiqOptions.html +++ b/doc/SidekiqUniqueJobs/RSpec/Matchers/HaveValidSidekiqOptions.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::RSpec::Matchers::HaveValidSidekiqOptions - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -585,9 +585,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Redis.html b/doc/SidekiqUniqueJobs/Redis.html index daddebb9e..4da27bda5 100644 --- a/doc/SidekiqUniqueJobs/Redis.html +++ b/doc/SidekiqUniqueJobs/Redis.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Redis - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -132,9 +132,9 @@

    Overview

    diff --git a/doc/SidekiqUniqueJobs/Redis/Entity.html b/doc/SidekiqUniqueJobs/Redis/Entity.html index 4951aab97..f18611343 100644 --- a/doc/SidekiqUniqueJobs/Redis/Entity.html +++ b/doc/SidekiqUniqueJobs/Redis/Entity.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Redis::Entity - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -1661,9 +1661,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Redis/Hash.html b/doc/SidekiqUniqueJobs/Redis/Hash.html index b5ecf7c7e..10da75e90 100644 --- a/doc/SidekiqUniqueJobs/Redis/Hash.html +++ b/doc/SidekiqUniqueJobs/Redis/Hash.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Redis::Hash - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -535,9 +535,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Redis/List.html b/doc/SidekiqUniqueJobs/Redis/List.html index d01c692bd..7d814463b 100644 --- a/doc/SidekiqUniqueJobs/Redis/List.html +++ b/doc/SidekiqUniqueJobs/Redis/List.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Redis::List - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -331,9 +331,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Redis/Set.html b/doc/SidekiqUniqueJobs/Redis/Set.html index 9ba1cce7e..1cc2d6a54 100644 --- a/doc/SidekiqUniqueJobs/Redis/Set.html +++ b/doc/SidekiqUniqueJobs/Redis/Set.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Redis::Set - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -327,9 +327,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Redis/SortedSet.html b/doc/SidekiqUniqueJobs/Redis/SortedSet.html index 122535af5..a14670297 100644 --- a/doc/SidekiqUniqueJobs/Redis/SortedSet.html +++ b/doc/SidekiqUniqueJobs/Redis/SortedSet.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Redis::SortedSet - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -131,6 +131,81 @@

    Direct Known Subclasses

    Changelog, Digests

    + +

    + Constant Summary + collapse +

    + +
    + +
    DEFAULT_COUNT = +
    +
    +

    Returns the number of matches to return by default.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Integer) + + + + — +

      the number of matches to return by default

      +
      + +
    • + +
    + +
    +
    +
    1_000
    + +
    SCAN_PATTERN = +
    +
    +

    Returns the default pattern to use for matching.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +

      the default pattern to use for matching

      +
      + +
    • + +
    + +
    +
    +
    "*"
    + +
    + + @@ -369,23 +444,23 @@

     
     
    -33
    -34
    -35
    -36
    -37
    -38
    -39
    -40
    -41
    +41 +42 +43 +44 +45 +46 +47 +48 +49

    -
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 33
    +      
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 41
     
     def add(values)
       redis do |conn|
         if values.is_a?(Array)
    -      conn.zadd(key, values)
    +      conn.zadd(key, *values)
         else
           conn.zadd(key, now_f, values)
         end
    @@ -438,12 +513,12 @@ 

     
     
    -71
    -72
    -73
    +79 +80 +81

    -
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 71
    +      
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 79
     
     def clear
       redis { |conn| conn.zremrangebyrank(key, 0, count) }
    @@ -495,12 +570,12 @@ 

     
     
    -81
    -82
    -83
    +89 +90 +91

    -
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 81
    +      
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 89
     
     def count
       redis { |conn| conn.zcard(key) }
    @@ -586,21 +661,23 @@ 

     
     
    -19
    -20
    -21
    -22
    -23
    -24
    +26 +27 +28 +29 +30 +31 +32

    -
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 19
    +      
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 26
     
     def entries(with_scores: true)
    -  entrys = redis { |conn| conn.zrange(key, 0, -1, with_scores: with_scores) }
    -  return entrys unless with_scores
    +  return redis { |conn| conn.zrange(key, 0, -1) } unless with_scores
     
    -  entrys.each_with_object({}) { |pair, hash| hash[pair[0]] = pair[1] }
    +  redis { |conn| conn.zrange(key, 0, -1, "withscores") }.each_with_object({}) do |pair, hash|
    +    hash[pair[0]] = pair[1]
    +  end
     end
    @@ -664,12 +741,12 @@

     
     
    -50
    -51
    -52
    +58 +59 +60

    -
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 50
    +      
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 58
     
     def rank(member)
       redis { |conn| conn.zrank(key, member) }
    @@ -736,12 +813,12 @@ 

     
     
    -61
    -62
    -63
    +69 +70 +71

    -
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 61
    +      
    # File 'lib/sidekiq_unique_jobs/redis/sorted_set.rb', line 69
     
     def score(member)
       redis { |conn| conn.zscore(key, member) }
    @@ -756,9 +833,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Redis/String.html b/doc/SidekiqUniqueJobs/Redis/String.html index 1c6999643..3911638aa 100644 --- a/doc/SidekiqUniqueJobs/Redis/String.html +++ b/doc/SidekiqUniqueJobs/Redis/String.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Redis::String - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -194,7 +194,7 @@

  • - #set(obj) ⇒ true, false + #set(obj, pipeline = nil) ⇒ true, false @@ -317,12 +317,12 @@

     
     
    -44
    -45
    -46
    +46 +47 +48

  • -
    # File 'lib/sidekiq_unique_jobs/redis/string.rb', line 44
    +      
    # File 'lib/sidekiq_unique_jobs/redis/string.rb', line 46
     
     def count
       exist? ? 1 : 0
    @@ -357,12 +357,12 @@ 

     
     
    -35
    -36
    -37
    +37 +38 +39

    -
    # File 'lib/sidekiq_unique_jobs/redis/string.rb', line 35
    +      
    # File 'lib/sidekiq_unique_jobs/redis/string.rb', line 37
     
     def del(*)
       redis { |conn| conn.del(key) }
    @@ -375,7 +375,7 @@ 

    - #set(obj) ⇒ true, false + #set(obj, pipeline = nil) ⇒ true, false @@ -431,12 +431,16 @@

    28 29 -30

    +30 +31 +32
    # File 'lib/sidekiq_unique_jobs/redis/string.rb', line 28
     
    -def set(obj)
    +def set(obj, pipeline = nil)
    +  return pipeline.set(key, obj) if pipeline
    +
       redis { |conn| conn.set(key, obj) }
     end
    @@ -502,9 +506,9 @@

    diff --git a/doc/SidekiqUniqueJobs/RedisScript.html b/doc/SidekiqUniqueJobs/RedisScript.html new file mode 100644 index 000000000..0c3208fad --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript.html @@ -0,0 +1,488 @@ + + + + + + + Module: SidekiqUniqueJobs::RedisScript + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: SidekiqUniqueJobs::RedisScript + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script.rb,
    + lib/sidekiq_unique_jobs/redis_script/dsl.rb,
    lib/sidekiq_unique_jobs/redis_script/client.rb,
    lib/sidekiq_unique_jobs/redis_script/config.rb,
    lib/sidekiq_unique_jobs/redis_script/script.rb,
    lib/sidekiq_unique_jobs/redis_script/timing.rb,
    lib/sidekiq_unique_jobs/redis_script/logging.rb,
    lib/sidekiq_unique_jobs/redis_script/scripts.rb,
    lib/sidekiq_unique_jobs/redis_script/template.rb,
    lib/sidekiq_unique_jobs/redis_script/lua_error.rb
    +
    +
    + +
    + +

    Overview

    +
    +

    Interface to dealing with .lua files

    + + +
    +
    +
    + +

    Author:

    + + +

    Defined Under Namespace

    +

    + + + Modules: DSL, Logging, Timing + + + + Classes: Client, Config, LuaError, Misconfiguration, Script, Scripts, Template + + +

    + + + + + + + + +

    + Class Method Summary + collapse +

    + + + + + + +
    +

    Class Method Details

    + + +
    +

    + + .execute(script_name, conn, keys: [], argv: []) ⇒ Object + + + + + +

    +
    +

    Execute the given script_name

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + script_name + + + (Symbol) + + + + — +

      the name of the lua script

      +
      + +
    • + +
    • + + keys + + + (Array<String>) + + + (defaults to: []) + + + — +

      script keys

      +
      + +
    • + +
    • + + argv + + + (Array<Object>) + + + (defaults to: []) + + + — +

      script arguments

      +
      + +
    • + +
    • + + conn + + + (Redis) + + + + — +

      the redis connection to use

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + + + + + +

      value from script

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +54
    +55
    +56
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script.rb', line 54
    +
    +def execute(script_name, conn, keys: [], argv: [])
    +  Client.execute(script_name, conn, keys: keys, argv: argv)
    +end
    +
    +
    + +
    +

    + + .loggerLogger + + + + + +

    +
    +

    The current logger

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Logger) + + + + — +

      the configured logger

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +28
    +29
    +30
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script.rb', line 28
    +
    +def logger
    +  config.logger
    +end
    +
    +
    + +
    +

    + + .logger=(other) ⇒ Logger + + + + + +

    +
    +

    Set a new logger

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + other + + + (Logger) + + + + — +

      another logger

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Logger) + + + + — +

      the new logger

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +39
    +40
    +41
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script.rb', line 39
    +
    +def logger=(other)
    +  config.logger = other
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Client.html b/doc/SidekiqUniqueJobs/RedisScript/Client.html new file mode 100644 index 000000000..1af104df2 --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Client.html @@ -0,0 +1,720 @@ + + + + + + + Class: SidekiqUniqueJobs::RedisScript::Client + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: SidekiqUniqueJobs::RedisScript::Client + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    Timing
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/client.rb
    +
    + +
    + +

    Overview

    +
    +

    Interface to dealing with .lua files

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #config ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute config.

      +
      + +
    • + + +
    • + + + #file_name ⇒ String + + + + + + + + + readonly + + + + + + + + + +

      The name of the file to execute.

      +
      + +
    • + + +
    • + + + #logger ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute logger.

      +
      + +
    • + + +
    • + + + #scripts ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute scripts.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(config) ⇒ Client + + + + + +

    +
    +

    Returns a new instance of Client.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +24
    +25
    +26
    +27
    +28
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/client.rb', line 24
    +
    +def initialize(config)
    +  @config  = config
    +  @logger  = config.logger
    +  @scripts = Scripts.fetch(config.scripts_path)
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #configObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute config.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +18
    +19
    +20
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/client.rb', line 18
    +
    +def config
    +  @config
    +end
    +
    +
    + + + +
    +

    + + #file_nameString (readonly) + + + + + +

    +
    +

    Returns The name of the file to execute.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +

      The name of the file to execute

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +18
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/client.rb', line 18
    +
    +attr_reader :config
    +
    +
    + + + +
    +

    + + #loggerObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute logger.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +14
    +15
    +16
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/client.rb', line 14
    +
    +def logger
    +  @logger
    +end
    +
    +
    + + + +
    +

    + + #scriptsObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute scripts.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/client.rb', line 22
    +
    +def scripts
    +  @scripts
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #execute(script_name, conn, keys: [], argv: []) ⇒ Object + + + + + +

    +
    + +
    + Note: +

    this method is recursive if we need to load a lua script +that wasn't previously loaded.

    +
    +
    + +

    Execute a lua script with the provided script_name

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + script_name + + + (Symbol) + + + + — +

      the name of the script to execute

      +
      + +
    • + +
    • + + conn + + + (Redis) + + + + — +

      the redis connection to use for execution

      +
      + +
    • + +
    • + + keys + + + (Array<String>) + + + (defaults to: []) + + + — +

      script keys

      +
      + +
    • + +
    • + + argv + + + (Array<Object>) + + + (defaults to: []) + + + — +

      script arguments

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + + + + + +

      value from script

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/client.rb', line 43
    +
    +def execute(script_name, conn, keys: [], argv: [])
    +  result, elapsed = timed do
    +    scripts.execute(script_name, conn, keys: keys, argv: argv)
    +  end
    +
    +  logger.debug("Executed #{script_name}.lua in #{elapsed}ms")
    +  result
    +rescue ::Redis::CommandError => ex
    +  handle_error(script_name, conn, ex) do
    +    execute(script_name, conn, keys: keys, argv: argv)
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Config.html b/doc/SidekiqUniqueJobs/RedisScript/Config.html new file mode 100644 index 000000000..d63f841e7 --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Config.html @@ -0,0 +1,376 @@ + + + + + + + Class: SidekiqUniqueJobs::RedisScript::Config + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: SidekiqUniqueJobs::RedisScript::Config + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/config.rb
    +
    + +
    + +

    Overview

    +
    +

    Class holding gem configuration

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #logger ⇒ Object + + + + + + + + + + + + + + + + +

      Returns the value of attribute logger.

      +
      + +
    • + + +
    • + + + #scripts_path ⇒ Object + + + + + + + + + + + + + + + + +

      Returns the value of attribute scripts_path.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initializeConfig + + + + + +

    +
    +

    Initialize a new instance of SidekiqUniqueJobs::RedisScript::Config

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +23
    +24
    +25
    +26
    +27
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/config.rb', line 23
    +
    +def initialize
    +  @conn         = RedisClient.new
    +  @logger       = Logger.new($stdout)
    +  @scripts_path = nil
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #loggerObject + + + + + +

    +
    +

    Returns the value of attribute logger.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +13
    +14
    +15
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/config.rb', line 13
    +
    +def logger
    +  @logger
    +end
    +
    +
    + + + +
    +

    + + #scripts_pathObject + + + + + +

    +
    +

    Returns the value of attribute scripts_path.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/config.rb', line 17
    +
    +def scripts_path
    +  @scripts_path
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/DSL.html b/doc/SidekiqUniqueJobs/RedisScript/DSL.html new file mode 100644 index 000000000..761d90d00 --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/DSL.html @@ -0,0 +1,161 @@ + + + + + + + Module: SidekiqUniqueJobs::RedisScript::DSL + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: SidekiqUniqueJobs::RedisScript::DSL + + + +

    +
    + + + + + + + + + +
    +
    Included in:
    +
    Script
    +
    + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/dsl.rb
    +
    + +
    + +

    Overview

    +
    +

    Interface to dealing with .lua files

    + + +
    +
    +
    + +

    Author:

    + + +

    Defined Under Namespace

    +

    + + + Modules: ClassMethods + + + + +

    + + +

    + Constant Summary + collapse +

    + +
    + +
    MUTEX = + +
    +
    Mutex.new
    + +
    + + + + + + + + + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/DSL/ClassMethods.html b/doc/SidekiqUniqueJobs/RedisScript/DSL/ClassMethods.html new file mode 100644 index 000000000..f2f49b873 --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/DSL/ClassMethods.html @@ -0,0 +1,432 @@ + + + + + + + Module: SidekiqUniqueJobs::RedisScript::DSL::ClassMethods + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: SidekiqUniqueJobs::RedisScript::DSL::ClassMethods + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/dsl.rb
    +
    + +
    + +

    Overview

    +
    +

    Module ClassMethods extends the base class with necessary methods

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #configRedisScript::Config + + + + + +

    +
    +

    The current configuration (See: #configure on how to configure)

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +52
    +53
    +54
    +55
    +56
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/dsl.rb', line 52
    +
    +def config
    +  MUTEX.synchronize do
    +    @config ||= Config.new
    +  end
    +end
    +
    +
    + +
    +

    + + #configure(options = {}) { ... } ⇒ Object + + + + + +

    +
    +

    Configure the gem

    + +

    This is usually called once at startup of an application

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + options + + + (Hash) + + + (defaults to: {}) + + + — +

      global gem options

      +
      + +
    • + +
    + + + + +

    Options Hash (options):

    +
      + +
    • + :path + (String, Pathname) + + + + +
    • + +
    • + :logger + (Logger) + + + — default: + default is Logger.new(STDOUT) + + + +
    • + +
    + + +

    Yields:

    +
      + +
    • + + + + + + + +

      control to the caller when given block

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +36
    +37
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/dsl.rb', line 36
    +
    +def configure(options = {})
    +  if block_given?
    +    yield config
    +  else
    +    options.each do |key, val|
    +      config.send(:"#{key}=", val)
    +    end
    +  end
    +end
    +
    +
    + +
    +

    + + #execute(file_name, conn, keys: [], argv: []) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +23
    +24
    +25
    +26
    +27
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/dsl.rb', line 23
    +
    +def execute(file_name, conn, keys: [], argv: [])
    +  SidekiqUniqueJobs::RedisScript::Client
    +    .new(config)
    +    .execute(file_name, conn, keys: keys, argv: argv)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Logging.html b/doc/SidekiqUniqueJobs/RedisScript/Logging.html new file mode 100644 index 000000000..65ed831dc --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Logging.html @@ -0,0 +1,745 @@ + + + + + + + Module: SidekiqUniqueJobs::RedisScript::Logging + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: SidekiqUniqueJobs::RedisScript::Logging + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/logging.rb
    +
    + +
    + +

    Overview

    +
    +

    Utility module for reducing the number of uses of logger.

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #log_debug(message_or_exception = nil) {|String, Exception| ... } ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    Logs a message at debug level

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + message_or_exception + + + (String, Exception) + + + (defaults to: nil) + + + — +

      the message or exception to log

      +
      + +
    • + +
    + +

    Yields:

    +
      + +
    • + + + (String, Exception) + + + + — +

      the message or exception to use for log message

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +36
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/logging.rb', line 33
    +
    +def log_debug(message_or_exception = nil, &block)
    +  logger.debug(message_or_exception, &block)
    +  nil
    +end
    +
    +
    + +
    +

    + + #log_error(message_or_exception = nil) {|String, Exception| ... } ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    Logs a message at error level

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + message_or_exception + + + (String, Exception) + + + (defaults to: nil) + + + — +

      the message or exception to log

      +
      + +
    • + +
    + +

    Yields:

    +
      + +
    • + + + (String, Exception) + + + + — +

      the message or exception to use for log message

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +75
    +76
    +77
    +78
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/logging.rb', line 75
    +
    +def log_error(message_or_exception = nil, &block)
    +  logger.error(message_or_exception, &block)
    +  nil
    +end
    +
    +
    + +
    +

    + + #log_fatal(message_or_exception = nil) {|String, Exception| ... } ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    Logs a message at fatal level

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + message_or_exception + + + (String, Exception) + + + (defaults to: nil) + + + — +

      the message or exception to log

      +
      + +
    • + +
    + +

    Yields:

    +
      + +
    • + + + (String, Exception) + + + + — +

      the message or exception to use for log message

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +89
    +90
    +91
    +92
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/logging.rb', line 89
    +
    +def log_fatal(message_or_exception = nil, &block)
    +  logger.fatal(message_or_exception, &block)
    +  nil
    +end
    +
    +
    + +
    +

    + + #log_info(message_or_exception = nil) {|String, Exception| ... } ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    Logs a message at info level

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + message_or_exception + + + (String, Exception) + + + (defaults to: nil) + + + — +

      the message or exception to log

      +
      + +
    • + +
    + +

    Yields:

    +
      + +
    • + + + (String, Exception) + + + + — +

      the message or exception to use for log message

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +47
    +48
    +49
    +50
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/logging.rb', line 47
    +
    +def log_info(message_or_exception = nil, &block)
    +  logger.info(message_or_exception, &block)
    +  nil
    +end
    +
    +
    + +
    +

    + + #log_warn(message_or_exception = nil) {|String, Exception| ... } ⇒ void + + + + + +

    +
    +

    This method returns an undefined value.

    Logs a message at warn level

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + message_or_exception + + + (String, Exception) + + + (defaults to: nil) + + + — +

      the message or exception to log

      +
      + +
    • + +
    + +

    Yields:

    +
      + +
    • + + + (String, Exception) + + + + — +

      the message or exception to use for log message

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +61
    +62
    +63
    +64
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/logging.rb', line 61
    +
    +def log_warn(message_or_exception = nil, &block)
    +  logger.warn(message_or_exception, &block)
    +  nil
    +end
    +
    +
    + +
    +

    + + #loggerLogger + + + + + +

    +
    +

    A convenience method for using the configured gem logger

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Logger) + + + +
    • + +
    + +

    See Also:

    +
      + +
    • RedisScript#.logger
    • + +
    + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/logging.rb', line 20
    +
    +def logger
    +  SidekiqUniqueJobs::RedisScript.logger
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/LuaError.html b/doc/SidekiqUniqueJobs/RedisScript/LuaError.html new file mode 100644 index 000000000..9fbdccdc3 --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/LuaError.html @@ -0,0 +1,662 @@ + + + + + + + Exception: SidekiqUniqueJobs::RedisScript::LuaError + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: SidekiqUniqueJobs::RedisScript::LuaError + + + +

    +
    + +
    +
    Inherits:
    +
    + RuntimeError + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/lua_error.rb
    +
    + +
    + +

    Overview

    +
    +

    LuaError raised on errors in Lua scripts

    + + +
    +
    +
    + +

    Author:

    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    PATTERN = +
    +
    +

    Reformats errors raised by redis representing failures while executing +a lua script. The default errors have confusing messages and backtraces, +and a type of +RuntimeError+. This class improves the message and +modifies the backtrace to include the lua script itself in a reasonable +way.

    + + +
    +
    +
    + + +
    +
    +
    /ERR Error (compiling|running) script \(.*?\): .*?:(\d+): (.*)/.freeze
    + +
    LIB_PATH = + +
    +
    File.expand_path("..", __dir__).freeze
    + +
    CONTEXT_LINE_NUMBER = + +
    +
    2
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #content ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute content.

      +
      + +
    • + + +
    • + + + #error ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute error.

      +
      + +
    • + + +
    • + + + #file ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute file.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(error, script) ⇒ LuaError + + + + + +

    +
    +

    Initialize a new SidekiqUniqueJobs::RedisScript::LuaError from an existing redis error, adjusting +the message and backtrace in the process.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + error + + + (StandardError) + + + + — +

      the original error raised by redis

      +
      + +
    • + +
    • + + script + + + (Script) + + + + — +

      a DTO with information about the script

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/lua_error.rb', line 43
    +
    +def initialize(error, script)
    +  @error        = error
    +  @file         = script.path
    +  @content      = script.source
    +  @backtrace    = @error.backtrace
    +
    +  @error.message.match(PATTERN) do |regexp_match|
    +    line_number   = regexp_match[2].to_i
    +    message       = regexp_match[3]
    +    error_context = generate_error_context(content, line_number)
    +
    +    super("#{message}\n\n#{error_context}\n\n")
    +    set_backtrace(generate_backtrace(file, line_number))
    +  end
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #contentObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute content.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +27
    +28
    +29
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/lua_error.rb', line 27
    +
    +def content
    +  @content
    +end
    +
    +
    + + + +
    +

    + + #errorObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute error.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +27
    +28
    +29
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/lua_error.rb', line 27
    +
    +def error
    +  @error
    +end
    +
    +
    + + + +
    +

    + + #fileObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute file.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +27
    +28
    +29
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/lua_error.rb', line 27
    +
    +def file
    +  @file
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .intercepts?(error) ⇒ Boolean + + + + + +

    +
    +

    Is this error one that should be reformatted?

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + error + + + (StandardError) + + + + — +

      the original error raised by redis

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +

      is this an error that should be reformatted?

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/lua_error.rb', line 33
    +
    +def self.intercepts?(error)
    +  PATTERN.match?(error.message)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Misconfiguration.html b/doc/SidekiqUniqueJobs/RedisScript/Misconfiguration.html new file mode 100644 index 000000000..fc71ab20f --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Misconfiguration.html @@ -0,0 +1,149 @@ + + + + + + + Exception: SidekiqUniqueJobs::RedisScript::Misconfiguration + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Exception: SidekiqUniqueJobs::RedisScript::Misconfiguration + + + +

    +
    + +
    +
    Inherits:
    +
    + RuntimeError + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/lua_error.rb
    +
    + +
    + +

    Overview

    +
    +

    Misconfiguration is raised when gem is misconfigured

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + + + + + + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Script.html b/doc/SidekiqUniqueJobs/RedisScript/Script.html new file mode 100644 index 000000000..b75e67c65 --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Script.html @@ -0,0 +1,1251 @@ + + + + + + + Class: SidekiqUniqueJobs::RedisScript::Script + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: SidekiqUniqueJobs::RedisScript::Script + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/script.rb
    +
    + +
    + +

    Overview

    +
    +

    Interface to dealing with .lua files

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #call_count ⇒ Object + + + + + + + + + + + + + + + + +

      Returns the value of attribute call_count.

      +
      + +
    • + + +
    • + + + #name ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute name.

      +
      + +
    • + + +
    • + + + #path ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute path.

      +
      + +
    • + + +
    • + + + #root_path ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute root_path.

      +
      + +
    • + + +
    • + + + #script_name ⇒ Symbol, String + + + + + + + + + readonly + + + + + + + + + +

      The name of the script without extension.

      +
      + +
    • + + +
    • + + + #script_path ⇒ String + + + + + + + + + readonly + + + + + + + + + +

      The path to the script on disk.

      +
      + +
    • + + +
    • + + + #sha ⇒ Object + + + + + + + + + + + + + + + + +

      Returns the value of attribute sha.

      +
      + +
    • + + +
    • + + + #source ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute source.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(name:, root_path:) ⇒ Script + + + + + +

    +
    +

    Returns a new instance of Script.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 39
    +
    +def initialize(name:, root_path:)
    +  @name      = name
    +  @root_path = root_path
    +  @path      = root_path.join("#{name}.lua").to_s
    +  @source    = render_file
    +  @sha       = compiled_sha
    +  @call_count = 0
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #call_countObject + + + + + +

    +
    +

    Returns the value of attribute call_count.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +37
    +38
    +39
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 37
    +
    +def call_count
    +  @call_count
    +end
    +
    +
    + + + +
    +

    + + #nameObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute name.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 17
    +
    +def name
    +  @name
    +end
    +
    +
    + + + +
    +

    + + #pathObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute path.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +21
    +22
    +23
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 21
    +
    +def path
    +  @path
    +end
    +
    +
    + + + +
    +

    + + #root_pathObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute root_path.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 25
    +
    +def root_path
    +  @root_path
    +end
    +
    +
    + + + +
    +

    + + #script_nameSymbol, String (readonly) + + + + + +

    +
    +

    Returns the name of the script without extension.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Symbol, String) + + + + — +

      the name of the script without extension

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +17
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 17
    +
    +attr_reader :name
    +
    +
    + + + +
    +

    + + #script_pathString (readonly) + + + + + +

    +
    +

    Returns the path to the script on disk.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +

      the path to the script on disk

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +21
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 21
    +
    +attr_reader :path
    +
    +
    + + + +
    +

    + + #shaObject + + + + + +

    +
    +

    Returns the value of attribute sha.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 33
    +
    +def sha
    +  @sha
    +end
    +
    +
    + + + +
    +

    + + #sourceObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute source.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +29
    +30
    +31
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 29
    +
    +def source
    +  @source
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .load(name, root_path, conn) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +9
    +10
    +11
    +12
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 9
    +
    +def self.load(name, root_path, conn)
    +  script = new(name: name, root_path: root_path)
    +  script.load(conn)
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #==(other) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +48
    +49
    +50
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 48
    +
    +def ==(other)
    +  sha == compiled_sha && compiled_sha == other.sha
    +end
    +
    +
    + +
    +

    + + #changed?Boolean + + + + + +

    +
    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 56
    +
    +def changed?
    +  compiled_sha != sha
    +end
    +
    +
    + +
    +

    + + #compiled_shaObject + + + + + +

    + + + + +
    +
    +
    +
    +64
    +65
    +66
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 64
    +
    +def compiled_sha
    +  Digest::SHA1.hexdigest(source)
    +end
    +
    +
    + +
    +

    + + #increment_call_countObject + + + + + +

    + + + + +
    +
    +
    +
    +52
    +53
    +54
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 52
    +
    +def increment_call_count
    +  @call_count += 1
    +end
    +
    +
    + +
    +

    + + #load(conn) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 68
    +
    +def load(conn)
    +  @sha =
    +    if conn.respond_to?(:namespace)
    +      conn.redis.script(:load, source)
    +    else
    +      conn.script(:load, source)
    +    end
    +
    +  self
    +end
    +
    +
    + +
    +

    + + #render_fileObject + + + + + +

    + + + + +
    +
    +
    +
    +60
    +61
    +62
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/script.rb', line 60
    +
    +def render_file
    +  Template.new(root_path).render(path)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Scripts.html b/doc/SidekiqUniqueJobs/RedisScript/Scripts.html new file mode 100644 index 000000000..b35c534ac --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Scripts.html @@ -0,0 +1,1216 @@ + + + + + + + Class: SidekiqUniqueJobs::RedisScript::Scripts + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: SidekiqUniqueJobs::RedisScript::Scripts + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/scripts.rb
    +
    + +
    + +

    Overview

    +
    +

    Interface to dealing with .lua files

    + + +
    +
    +
    + +

    Author:

    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    SCRIPT_PATHS = +
    +
    +

    Returns a map with configured script paths.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Concurrent::Map) + + + + — +

      a map with configured script paths

      +
      + +
    • + +
    + +
    +
    +
    Concurrent::Map.new
    + +
    + + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #root_path ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute root_path.

      +
      + +
    • + + +
    • + + + #scripts ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute scripts.

      +
      + +
    • + + +
    + + + + + +

    + Class Method Summary + collapse +

    + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(path) ⇒ Scripts + + + + + +

    +
    +

    Returns a new instance of Scripts.

    + + +
    +
    +
    + +

    Raises:

    +
      + +
    • + + + (ArgumentError) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +62
    +63
    +64
    +65
    +66
    +67
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 62
    +
    +def initialize(path)
    +  raise ArgumentError, "path needs to be a Pathname" unless path.is_a?(Pathname)
    +
    +  @scripts   = Concurrent::Map.new
    +  @root_path = path
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #root_pathObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute root_path.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +60
    +61
    +62
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 60
    +
    +def root_path
    +  @root_path
    +end
    +
    +
    + + + +
    +

    + + #scriptsObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute scripts.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +55
    +56
    +57
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 55
    +
    +def scripts
    +  @scripts
    +end
    +
    +
    + +
    + + +
    +

    Class Method Details

    + + +
    +

    + + .create(root_path) ⇒ Scripts + + + + + +

    +
    +

    Create a new scripts collection based on path

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + root_path + + + (Pathname) + + + + — +

      the path to scripts

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Scripts) + + + + — +

      a collection of scripts

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 35
    +
    +def self.create(root_path)
    +  scripts = new(root_path)
    +  store(scripts)
    +end
    +
    +
    + +
    +

    + + .fetch(root_path) ⇒ Scripts + + + + + +

    +
    +

    Fetch a scripts configuration for path

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + root_path + + + (Pathname) + + + + — +

      the path to scripts

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Scripts) + + + + — +

      a collection of scripts

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 20
    +
    +def self.fetch(root_path)
    +  if (scripts = SCRIPT_PATHS.get(root_path))
    +    return scripts
    +  end
    +
    +  create(root_path)
    +end
    +
    +
    + +
    +

    + + .store(scripts) ⇒ Scripts + + + + + +

    +
    +

    Store the scripts collection in memory

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scripts + + + (Scripts) + + + + — +

      the path to scripts

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Scripts) + + + + — +

      the scripts instance that was stored

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +47
    +48
    +49
    +50
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 47
    +
    +def self.store(scripts)
    +  SCRIPT_PATHS.put(scripts.root_path, scripts)
    +  scripts
    +end
    +
    +
    + +
    + +
    +

    Instance Method Details

    + + +
    +

    + + #countObject + + + + + +

    + + + + +
    +
    +
    +
    +118
    +119
    +120
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 118
    +
    +def count
    +  scripts.keys.size
    +end
    +
    +
    + +
    +

    + + #delete(script) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 84
    +
    +def delete(script)
    +  if script.is_a?(Script)
    +    scripts.delete(script.name)
    +  else
    +    scripts.delete(script.to_sym)
    +  end
    +end
    +
    +
    + +
    +

    + + #execute(name, conn, keys: [], argv: []) ⇒ Object + + + + + +

    +
    + +
    + Note: +

    this method is recursive if we need to load a lua script +that wasn't previously loaded.

    +
    +
    + +

    Execute a lua script with given name

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (Symbol) + + + + — +

      the name of the script to execute

      +
      + +
    • + +
    • + + conn + + + (Redis) + + + + — +

      the redis connection to use for execution

      +
      + +
    • + +
    • + + keys + + + (Array<String>) + + + (defaults to: []) + + + — +

      script keys

      +
      + +
    • + +
    • + + argv + + + (Array<Object>) + + + (defaults to: []) + + + — +

      script arguments

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + + + + + +

      value from script

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +113
    +114
    +115
    +116
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 113
    +
    +def execute(name, conn, keys: [], argv: [])
    +  script = fetch(name, conn)
    +  conn.evalsha(script.sha, keys, argv)
    +end
    +
    +
    + +
    +

    + + #fetch(name, conn) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 69
    +
    +def fetch(name, conn)
    +  if (script = scripts.get(name.to_sym))
    +    return script
    +  end
    +
    +  load(name, conn)
    +end
    +
    +
    + +
    +

    + + #kill(conn) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 92
    +
    +def kill(conn)
    +  if conn.respond_to?(:namespace)
    +    conn.redis.script(:kill)
    +  else
    +    conn.script(:kill)
    +  end
    +end
    +
    +
    + +
    +

    + + #load(name, conn) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +77
    +78
    +79
    +80
    +81
    +82
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/scripts.rb', line 77
    +
    +def load(name, conn)
    +  script = Script.load(name, root_path, conn)
    +  scripts.put(name.to_sym, script)
    +
    +  script
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Template.html b/doc/SidekiqUniqueJobs/RedisScript/Template.html new file mode 100644 index 000000000..ad692a99d --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Template.html @@ -0,0 +1,403 @@ + + + + + + + Class: SidekiqUniqueJobs::RedisScript::Template + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: SidekiqUniqueJobs::RedisScript::Template + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/template.rb
    +
    + +
    + +

    Overview

    +
    +

    Class Template provides LUA script partial template rendering

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(script_path) ⇒ Template + + + + + +

    +
    +

    Returns a new instance of Template.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +14
    +15
    +16
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/template.rb', line 14
    +
    +def initialize(script_path)
    +  @script_path = script_path
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #include_partial(relative_path) ⇒ Object + + + + + +

    +
    +

    helper method to include a lua partial within another lua script

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/template.rb', line 33
    +
    +def include_partial(relative_path)
    +  return if @partial_templates.key?(relative_path)
    +
    +  @partial_templates[relative_path] = nil
    +  render(Pathname.new("#{@script_path}/#{relative_path}"))
    +end
    +
    +
    + +
    +

    + + #render(pathname) ⇒ String + + + + + +

    +
    +

    Renders a Lua script and includes any partials in that file + all <%= include_partial '' %> replaced with the actual contents of the partial

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + pathname + + + (Pathname) + + + + — +

      the path to the

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + + — +

      the rendered Luascript

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +26
    +27
    +28
    +29
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/template.rb', line 26
    +
    +def render(pathname)
    +  @partial_templates ||= {}
    +  ::ERB.new(File.read(pathname)).result(binding)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/RedisScript/Timing.html b/doc/SidekiqUniqueJobs/RedisScript/Timing.html new file mode 100644 index 000000000..786f3161c --- /dev/null +++ b/doc/SidekiqUniqueJobs/RedisScript/Timing.html @@ -0,0 +1,309 @@ + + + + + + + Module: SidekiqUniqueJobs::RedisScript::Timing + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: SidekiqUniqueJobs::RedisScript::Timing + + + +

    +
    + + + + + + + + + +
    +
    Included in:
    +
    Client
    +
    + + + +
    +
    Defined in:
    +
    lib/sidekiq_unique_jobs/redis_script/timing.rb
    +
    + +
    + +

    Overview

    +
    +

    Handles timing> of things

    + + +
    +
    +
    + +

    Author:

    + + +
    + + + + + + + +

    + Class Method Summary + collapse +

    + + + + + + +
    +

    Class Method Details

    + + +
    +

    + + .nowFloat + + + + + +

    +
    +

    Returns a float representation of the current time. + Either from Process or Time

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Float) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +30
    +31
    +32
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/timing.rb', line 30
    +
    +def now
    +  (Process.clock_gettime(Process::CLOCK_MONOTONIC) * 1000).to_i
    +end
    +
    +
    + +
    +

    + + .timedyield return, Float + + + + + +

    +
    +

    Used for timing method calls

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (yield return, Float) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +
    +
    # File 'lib/sidekiq_unique_jobs/redis_script/timing.rb', line 17
    +
    +def timed
    +  start_time = now
    +
    +  [yield, now - start_time]
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/SidekiqUniqueJobs/Reflectable.html b/doc/SidekiqUniqueJobs/Reflectable.html index fef022450..01bc62f11 100644 --- a/doc/SidekiqUniqueJobs/Reflectable.html +++ b/doc/SidekiqUniqueJobs/Reflectable.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Reflectable - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -247,9 +247,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Reflections.html b/doc/SidekiqUniqueJobs/Reflections.html index d8cc0a334..66adfe95a 100644 --- a/doc/SidekiqUniqueJobs/Reflections.html +++ b/doc/SidekiqUniqueJobs/Reflections.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Reflections - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -505,8 +505,8 @@

    # File 'lib/sidekiq_unique_jobs/reflections.rb', line 53
     
    -def dispatch(reflection, *args)
    -  if (block = @reflections[reflection])
    +def dispatch(reflection, *args) # rubocop:disable Metrics/MethodLength
    +  if (block = @reflections[reflection])
         block.call(*args)
     
         if DEPRECATIONS.key?(reflection)
    @@ -584,9 +584,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Script.html b/doc/SidekiqUniqueJobs/Script.html index 3306ed079..b874fc689 100644 --- a/doc/SidekiqUniqueJobs/Script.html +++ b/doc/SidekiqUniqueJobs/Script.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Script - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -73,7 +73,7 @@
    Includes:
    -
    Brpoplpush::RedisScript::DSL
    +
    RedisScript::DSL
    @@ -134,13 +134,14 @@

    Overview

    +
    diff --git a/doc/SidekiqUniqueJobs/Script/Caller.html b/doc/SidekiqUniqueJobs/Script/Caller.html index 68598bf6d..552da8435 100644 --- a/doc/SidekiqUniqueJobs/Script/Caller.html +++ b/doc/SidekiqUniqueJobs/Script/Caller.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Script::Caller - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -236,6 +236,28 @@

    +
    + + + + +
  • + + + .normalize_argv(argv) ⇒ Object + + + + + + + + + + + + +
  • @@ -565,12 +587,12 @@

     
     
    -108
    -109
    -110
    +103 +104 +105

    -
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 108
    +      
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 103
     
     def debug_lua
       SidekiqUniqueJobs.config.debug_lua
    @@ -616,25 +638,15 @@ 

    57 58 59 -60 -61 -62 -63 -64 -65

    +60
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 56
     
     def do_call(file_name, conn, keys, argv)
    -  argv = argv.dup.concat([
    -                           now_f,
    -                           debug_lua,
    -                           max_history,
    -                           file_name,
    -                           redis_version,
    -                         ])
    -  Script.execute(file_name, conn, keys: keys, argv: argv)
    +  argv = argv.dup.push(now_f, debug_lua, max_history, file_name, redis_version)
    +
    +  Script.execute(file_name, conn, keys: keys, argv: normalize_argv(argv))
     end
    @@ -847,20 +859,20 @@

     
     
    +81
    +82
    +83
    +84
    +85
     86
     87
     88
     89
     90
    -91
    -92
    -93
    -94
    -95
    -96
    +91

    -
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 86
    +      
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 81
     
     def extract_args(*args)
       options = args.extract_options!
    @@ -909,12 +921,12 @@ 

     
     
    -115
    -116
    -117
    +110 +111 +112

    -
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 115
    +      
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 110
     
     def max_history
       SidekiqUniqueJobs.config.max_history
    @@ -922,6 +934,50 @@ 

    + + +
    +

    + + .normalize_argv(argv) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +121
    +122
    +123
    +124
    +125
    +126
    +127
    +128
    +129
    +130
    +
    +
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 121
    +
    +def normalize_argv(argv)
    +  argv.each_with_index do |item, index|
    +    case item
    +    when FalseClass, NilClass
    +      argv[index] = 0
    +    when TrueClass
    +      argv[index] = 1
    +    end
    +  end
    +end
    +
    @@ -955,12 +1011,12 @@

     
     
    -101
    -102
    -103
    +96 +97 +98

    -
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 101
    +      
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 96
     
     def now_f
       SidekiqUniqueJobs.now_f
    @@ -1001,12 +1057,12 @@ 

     
     
    -122
    -123
    -124
    +117 +118 +119

    -
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 122
    +      
    # File 'lib/sidekiq_unique_jobs/script/caller.rb', line 117
     
     def redis_version
       SidekiqUniqueJobs.config.redis_version
    @@ -1021,9 +1077,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/Server.html b/doc/SidekiqUniqueJobs/Server.html index a105fb56f..577064b82 100644 --- a/doc/SidekiqUniqueJobs/Server.html +++ b/doc/SidekiqUniqueJobs/Server.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::Server - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -365,12 +365,12 @@

     
     
    +56
     57
    -58
    -59
    +58

    -
    # File 'lib/sidekiq_unique_jobs/server.rb', line 57
    +      
    # File 'lib/sidekiq_unique_jobs/server.rb', line 56
     
     def self.death_handler
       DEATH_HANDLER
    @@ -409,15 +409,13 @@ 

    35 36 37 -38 -39

    +38
    # File 'lib/sidekiq_unique_jobs/server.rb', line 34
     
     def self.start
       SidekiqUniqueJobs::UpdateVersion.call
    -  SidekiqUniqueJobs::UpgradeLocks.call
       SidekiqUniqueJobs::Orphans::Manager.start
       SidekiqUniqueJobs::Orphans::ReaperResurrector.start
     end
    @@ -451,12 +449,12 @@

     
     
    +46
     47
    -48
    -49
    +48

    -
    # File 'lib/sidekiq_unique_jobs/server.rb', line 47
    +      
    # File 'lib/sidekiq_unique_jobs/server.rb', line 46
     
     def self.stop
       SidekiqUniqueJobs::Orphans::Manager.stop
    @@ -471,9 +469,9 @@ 

    diff --git a/doc/SidekiqUniqueJobs/SidekiqWorkerMethods.html b/doc/SidekiqUniqueJobs/SidekiqWorkerMethods.html index 395446e22..35f8a2452 100644 --- a/doc/SidekiqUniqueJobs/SidekiqWorkerMethods.html +++ b/doc/SidekiqUniqueJobs/SidekiqWorkerMethods.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::SidekiqWorkerMethods - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -76,7 +76,7 @@
    Included in:
    -
    LockArgs, LockDigest, LockTTL, LockTimeout, OnConflict::Reschedule
    +
    LockArgs, LockDigest, LockTTL, LockTimeout, LockType, OnConflict::Reschedule
    @@ -117,21 +117,13 @@

    Overview

    - - - - -

    - Instance Method Summary - collapse -

    - -
      - -
    • +

      Instance Attribute Summary collapse

      + + + + + + +

      + Instance Method Summary + collapse +

      + +
      • - #default_worker_options ⇒ Hash<Symbol, Object> + #after_unlock_hook ⇒ Proc @@ -168,7 +176,7 @@

        -

        Returns the default worker options from Sidekiq.

        +

        The hook to call after a successful unlock.

      • @@ -177,7 +185,7 @@

      • - #sidekiq_worker_class? ⇒ true, false + #default_job_options ⇒ Hash<Symbol, Object> @@ -191,7 +199,7 @@

        -

        Tests that the.

        +

        Returns the default worker options from Sidekiq.

      • @@ -200,7 +208,7 @@

      • - #worker_class ⇒ Sidekiq::Worker + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker @@ -214,7 +222,7 @@

        -

        The Sidekiq::Worker implementation.

        +

        Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

      • @@ -223,7 +231,7 @@

      • - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #job_method_defined?(method_sym) ⇒ true, false @@ -237,7 +245,7 @@

        -

        Attempt to constantize a string worker_class argument, always failing back to the original argument when the constant can't be found.

        +

        Avoids duplicating worker_class.respond_to? in multiple places.

      • @@ -246,7 +254,7 @@

      • - #worker_method_defined?(method_sym) ⇒ true, false + #job_options ⇒ Hash @@ -260,7 +268,7 @@

        -

        Avoids duplicating worker_class.respond_to? in multiple places.

        +

        Wraps #get_sidekiq_options to always work with a hash.

      • @@ -269,7 +277,7 @@

      • - #worker_options ⇒ Hash + #sidekiq_job_class? ⇒ true, false @@ -283,7 +291,7 @@

        -

        Wraps #get_sidekiq_options to always work with a hash.

        +

        Tests that the.

      • @@ -293,15 +301,15 @@

        - -
        -

        Instance Method Details

        - +
        +

        Instance Attribute Details

        + +
        -

        +

        - #after_unlock_hookProc + #job_classObject @@ -309,26 +317,13 @@

        -

        The hook to call after a successful unlock

        +

        Returns the value of attribute job_class.

        -

        Returns:

        -
          - -
        • - - - (Proc) - - - -
        • - -
        @@ -336,37 +331,32 @@

         
         
        -37
        -38
        -39
        -40
        -41
        -42
        -43
        -44
        -45
        +11 +12 +13

        -
        # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 37
        -
        -def after_unlock_hook
        -  lambda do
        -    if @worker_class.respond_to?(:after_unlock)
        -      @worker_class.after_unlock # instance method in sidekiq v6
        -    elsif worker_class.respond_to?(:after_unlock)
        -      worker_class.after_unlock # class method regardless of sidekiq version
        -    end
        -  end
        +      
        # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 11
        +
        +def job_class
        +  @job_class
         end
        -
        -

        +

        + + +
        +

        Instance Method Details

        + + +
        +

        - #default_worker_optionsHash<Symbol, Object> + #after_unlock_hookProc @@ -374,7 +364,7 @@

        -

        Returns the default worker options from Sidekiq

        +

        The hook to call after a successful unlock

        @@ -387,7 +377,7 @@

      • - (Hash<Symbol, Object>) + (Proc) @@ -401,15 +391,47 @@

         
         
        -61
        -62
        -63
        +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 61
    -
    -def default_worker_options
    -  Sidekiq.default_worker_options
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 42
    +
    +def after_unlock_hook # rubocop:disable Metrics/MethodLength
    +  lambda do
    +    if @original_job_class.respond_to?(:after_unlock)
    +      # instance method in sidekiq v6
    +      if @original_job_class.method(:after_unlock).arity.positive? # arity check to maintain backwards compatibility
    +        @original_job_class.after_unlock(item)
    +      else
    +        @original_job_class.after_unlock
    +      end
    +    elsif job_class.respond_to?(:after_unlock)
    +      # class method regardless of sidekiq version
    +      if job_class.method(:after_unlock).arity.positive? # arity check to maintain backwards compatibility
    +        job_class.after_unlock(item)
    +      else
    +        job_class.after_unlock
    +      end
    +    end
    +  end
     end
    @@ -417,9 +439,9 @@

    -

    +

    - #sidekiq_worker_class?true, false + #default_job_optionsHash<Symbol, Object> @@ -427,7 +449,7 @@

    -

    Tests that the

    +

    Returns the default worker options from Sidekiq

    @@ -440,27 +462,10 @@

  • - (true) - - - - — -

    if worker_class responds to get_sidekiq_options

    -
    - -
  • - -
  • - - - (false) + (Hash<Symbol, Object>) - — -

    if worker_class does not respond to get_sidekiq_options

    -
    -
  • @@ -471,15 +476,23 @@

     
     
    -25
    -26
    -27
    +76 +77 +78 +79 +80 +81 +82

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 25
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 76
     
    -def sidekiq_worker_class?
    -  worker_method_defined?(:get_sidekiq_options)
    +def default_job_options
    +  if Sidekiq.respond_to?(:default_job_options)
    +    Sidekiq.default_job_options
    +  else
    +    Sidekiq.default_worker_options
    +  end
     end
    @@ -487,9 +500,9 @@

    -

    +

    - #worker_classSidekiq::Worker + #job_class_constantize(klazz = @job_class) ⇒ Sidekiq::Worker @@ -497,7 +510,8 @@

    -

    The Sidekiq::Worker implementation

    +

    Attempt to constantize a string worker_class argument, always +failing back to the original argument when the constant can't be found

    @@ -524,25 +538,25 @@

     
     
    -31
    -32
    -33
    +66 +67 +68

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 31
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 66
     
    -def worker_class
    -  @_worker_class ||= worker_class_constantize # rubocop:disable Naming/MemoizedInstanceVariableName
    -end
    +def job_class_constantize(klazz = @job_class) + SidekiqUniqueJobs.safe_constantize(klazz) +end
    -

    +

    - #worker_class_constantize(klazz = @worker_class) ⇒ Sidekiq::Worker + #job_method_defined?(method_sym) ⇒ true, false @@ -550,8 +564,7 @@

    -

    Attempt to constantize a string worker_class argument, always -failing back to the original argument when the constant can't be found

    +

    Avoids duplicating worker_class.respond_to? in multiple places

    @@ -564,7 +577,7 @@

  • - (Sidekiq::Worker) + (true, false) @@ -578,15 +591,15 @@

     
     
    -51
    -52
    -53
    +15 +16 +17

  • -
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 51
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 15
     
    -def worker_class_constantize(klazz = @worker_class)
    -  SidekiqUniqueJobs.safe_constantize(klazz)
    +def job_method_defined?(method_sym)
    +  job_class.respond_to?(method_sym)
     end
    @@ -594,9 +607,9 @@

    -

    +

    - #worker_method_defined?(method_sym) ⇒ true, false + #job_optionsHash @@ -604,7 +617,7 @@

    -

    Avoids duplicating worker_class.respond_to? in multiple places

    +

    Wraps #get_sidekiq_options to always work with a hash

    @@ -617,10 +630,14 @@

  • - (true, false) + (Hash) + — +

    of the worker class sidekiq options

    +
    +
  • @@ -631,15 +648,19 @@

     
     
    -10
    -11
    -12
    +21 +22 +23 +24 +25

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 10
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 21
     
    -def worker_method_defined?(method_sym)
    -  worker_class.respond_to?(method_sym)
    +def job_options
    +  return {} unless sidekiq_job_class?
    +
    +  job_class.get_sidekiq_options.deep_stringify_keys
     end
    @@ -647,9 +668,9 @@

    -

    +

    - #worker_optionsHash + #sidekiq_job_class?true, false @@ -657,7 +678,7 @@

    -

    Wraps #get_sidekiq_options to always work with a hash

    +

    Tests that the

    @@ -670,12 +691,25 @@

  • - (Hash) + (true) — -

    of the worker class sidekiq options

    +

    if job_class responds to get_sidekiq_options

    +
    + +
  • + +
  • + + + (false) + + + + — +

    if job_class does not respond to get_sidekiq_options

  • @@ -688,19 +722,15 @@

     
     
    -16
    -17
    -18
    -19
    -20
    +30 +31 +32

    -
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 16
    -
    -def worker_options
    -  return {} unless sidekiq_worker_class?
    +      
    # File 'lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb', line 30
     
    -  worker_class.get_sidekiq_options.deep_stringify_keys
    +def sidekiq_job_class?
    +  job_method_defined?(:get_sidekiq_options)
     end
    @@ -712,9 +742,9 @@

    diff --git a/doc/SidekiqUniqueJobs/TimerTask.html b/doc/SidekiqUniqueJobs/TimerTask.html index 4dd08b5c1..f6b3aad90 100644 --- a/doc/SidekiqUniqueJobs/TimerTask.html +++ b/doc/SidekiqUniqueJobs/TimerTask.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::TimerTask - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -69,12 +69,12 @@
    Inherits:
    - Concurrent::TimerTask + Concurrent::RubyExecutorService
    • Object
    • - + @@ -89,6 +89,11 @@ +
      +
      Includes:
      +
      Concurrent::Concern::Dereferenceable, Concurrent::Concern::Observable
      +
      + @@ -103,36 +108,948 @@

      Overview

      - +

      A very common concurrency pattern is to run a thread that performs a task at +regular intervals. The thread that performs the task sleeps for the given +interval then wakes up and performs the task. Lather, rinse, repeat... This +pattern causes two problems. First, it is difficult to test the business +logic of the task because the task itself is tightly coupled with the +concurrency logic. Second, an exception raised while performing the task can +cause the entire thread to abend. In a long-running application where the +task thread is intended to run for days/weeks/years a crashed task thread +can pose a significant problem. TimerTask alleviates both problems.

      + +

      When a TimerTask is launched it starts a thread for monitoring the +execution interval. The TimerTask thread does not perform the task, +however. Instead, the TimerTask launches the task on a separate thread. +Should the task experience an unrecoverable crash only the task thread will +crash. This makes the TimerTask very fault tolerant. Additionally, the +TimerTask thread can respond to the success or failure of the task, +performing logging or ancillary operations.

      + +

      One other advantage of TimerTask is that it forces the business logic to +be completely decoupled from the concurrency logic. The business logic can +be tested separately then passed to the TimerTask for scheduling and +running.

      + +

      In some cases it may be necessary for a TimerTask to affect its own +execution cycle. To facilitate this, a reference to the TimerTask instance +is passed as an argument to the provided block every time the task is +executed.

      + +

      The TimerTask class includes the Dereferenceable mixin module so the +result of the last execution is always available via the #value method. +Dereferencing options can be passed to the TimerTask during construction or +at any later time using the #set_deref_options method.

      + +

      TimerTask supports notification through the Ruby standard library +Observable module. On execution the TimerTask will notify the observers +with three arguments: time of execution, the result of the block (or nil on +failure), and any raised exceptions (or nil on success).

      +
      +
      +

      Examples:

      + + +

      Basic usage

      +

      + +
      task = Concurrent::TimerTask.new{ puts 'Boom!' }
      +task.execute
      +
      +task.execution_interval #=> 60 (default)
      +
      +# wait 60 seconds...
      +#=> 'Boom!'
      +
      +task.shutdown #=> true
      + + +

      Configuring :execution_interval

      +

      + +
      task = Concurrent::TimerTask.new(execution_interval: 5) do
      +       puts 'Boom!'
      +     end
      +
      +task.execution_interval #=> 5
      + + +

      Immediate execution with :run_now

      +

      + +
      task = Concurrent::TimerTask.new(run_now: true){ puts 'Boom!' }
      +task.execute
      +
      +#=> 'Boom!'
      + + +

      Last #value and Dereferenceable mixin

      +

      + +
      task = Concurrent::TimerTask.new(
      +  dup_on_deref: true,
      +  execution_interval: 5
      +){ Time.now }
      +
      +task.execute
      +Time.now   #=> 2013-11-07 18:06:50 -0500
      +sleep(10)
      +task.value #=> 2013-11-07 18:06:55 -0500
      + + +

      Controlling execution from within the block

      +

      + +
      timer_task = Concurrent::TimerTask.new(execution_interval: 1) do |task|
      +  task.execution_interval.times{ print 'Boom! ' }
      +  print "\n"
      +  task.execution_interval += 1
      +  if task.execution_interval > 5
      +    puts 'Stopping...'
      +    task.shutdown
      +  end
      +end
      +
      +timer_task.execute # blocking call - this task will stop itself
      +#=> Boom!
      +#=> Boom! Boom!
      +#=> Boom! Boom! Boom!
      +#=> Boom! Boom! Boom! Boom!
      +#=> Boom! Boom! Boom! Boom! Boom!
      +#=> Stopping...
      + + +

      Observation

      +

      + +
      class TaskObserver
      +  def update(time, result, ex)
      +    if result
      +      print "(#{time}) Execution successfully returned #{result}\n"
      +    else
      +      print "(#{time}) Execution failed with error #{ex}\n"
      +    end
      +  end
      +end
      +
      +task = Concurrent::TimerTask.new(execution_interval: 1){ 42 }
      +task.add_observer(TaskObserver.new)
      +task.execute
      +sleep 4
      +
      +#=> (2013-10-13 19:08:58 -0400) Execution successfully returned 42
      +#=> (2013-10-13 19:08:59 -0400) Execution successfully returned 42
      +#=> (2013-10-13 19:09:00 -0400) Execution successfully returned 42
      +task.shutdown
      +
      +task = Concurrent::TimerTask.new(execution_interval: 1){ sleep }
      +task.add_observer(TaskObserver.new)
      +task.execute
      +
      +#=> (2013-10-13 19:07:25 -0400) Execution timed out
      +#=> (2013-10-13 19:07:27 -0400) Execution timed out
      +#=> (2013-10-13 19:07:29 -0400) Execution timed out
      +task.shutdown
      +
      +task = Concurrent::TimerTask.new(execution_interval: 1){ raise StandardError }
      +task.add_observer(TaskObserver.new)
      +task.execute
      +
      +#=> (2013-10-13 19:09:37 -0400) Execution failed with error StandardError
      +#=> (2013-10-13 19:09:38 -0400) Execution failed with error StandardError
      +#=> (2013-10-13 19:09:39 -0400) Execution failed with error StandardError
      +task.shutdown
      + +
      +

      See Also:

      + +

      + Constant Summary + collapse +

      + +
      + +
      EXECUTION_INTERVAL = +
      +
      +

      Default :execution_interval in seconds.

      + + +
      +
      +
      + + +
      +
      +
      60
      + +
      TIMEOUT_INTERVAL = +
      +
      +

      Default :timeout_interval in seconds.

      + + +
      +
      +
      + + +
      +
      +
      30
      + +
      + + + + + +

      Instance Attribute Summary collapse

      +
        + +
      • + + + #execution_interval ⇒ Fixnum + + + + + + + + + + + + + + + + +

        Number of seconds after the task completes before the task is performed again.

        +
        + +
      • + + +
      + + + + + +

      + Class Method Summary + collapse +

      + + + +

      + Instance Method Summary + collapse +

      + + + + + + + +
      +

      Constructor Details

      + +
      +

      + + #initialize(opts = {}) {|task| ... } ⇒ TimerTask + + + +

      +
      +

      Create a new TimerTask with the given task and configuration.

      +
      +
      +
      +

      Parameters:

      +
        + +
      • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +

        the options defining task execution.

        +
        + +
      • + +
      + + + + +

      Options Hash (opts):

      +
        + +
      • + :execution_interval + (Integer) + + + + + —

        number of seconds between +task executions (default: EXECUTION_INTERVAL)

        +
        + +
      • + +
      • + :run_now + (Boolean) + + + + + —

        Whether to run the task immediately +upon instantiation or to wait until the first # execution_interval +has passed (default: false)

        +
        + +
      • + +
      + +

      Yields:

      +
        +
      • + + + + + + + +

        to the block after :execution_interval seconds have passed since +the last yield

        +
        + +
      • + +
      +

      Yield Parameters:

      +
        + +
      • + + task + + + + + + + — +

        a reference to the TimerTask instance so that the +block can control its own lifecycle. Necessary since self will +refer to the execution context of the block rather than the running +TimerTask.

        +
        + +
      • + +
      +

      Raises:

      +
        + +
      • + + + + + + + +

        ArgumentError when no block is given.

        +
        + +
      • + +
      + +
      + + + + +
      +
      +
      +
      +181
      +182
      +183
      +184
      +185
      +186
      +
      +
      # File 'lib/sidekiq_unique_jobs/timer_task.rb', line 181
      +
      +def initialize(opts = {}, &task)
      +  raise ArgumentError, "no block given" unless task
      +
      +  super
      +  set_deref_options opts
      +end
      +
      +
      + +
      + +
      +

      Instance Attribute Details

      + + + +
      +

      + + #execution_intervalFixnum + + + + + +

      +
      +

      Returns Number of seconds after the task completes before the +task is performed again.

      + + +
      +
      +
      + +

      Returns:

      +
        + +
      • + + + (Fixnum) + + + + — +

        Number of seconds after the task completes before the +task is performed again.

        +
        + +
      • + +
      + +
      + + + + +
      +
      +
      +
      +232
      +233
      +234
      +
      +
      # File 'lib/sidekiq_unique_jobs/timer_task.rb', line 232
      +
      +def execution_interval
      +  synchronize { @execution_interval }
      +end
      +
      +
      + +
      + + +
      +

      Class Method Details

      + + +
      +

      + + .execute(opts = {}) {|task| ... } ⇒ TimerTask + + + + + +

      +
      +

      Create and execute a new TimerTask.

      + + +
      +
      +
      + +
      +

      Examples:

      + + +
      task = Concurrent::TimerTask.execute(execution_interval: 10){ print "Hello World\n" }
      +task.running? #=> true
      + +
      +

      Parameters:

      +
        + +
      • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +

        the options defining task execution.

        +
        + +
      • + +
      + + + + +

      Options Hash (opts):

      +
        + +
      • + :execution_interval + (Integer) + + + + + —

        number of seconds between +task executions (default: EXECUTION_INTERVAL)

        +
        + +
      • + +
      • + :run_now + (Boolean) + + + + + —

        Whether to run the task immediately +upon instantiation or to wait until the first # execution_interval +has passed (default: false)

        +
        + +
      • + +
      + + +

      Yields:

      +
        + +
      • + + + + + + + +

        to the block after :execution_interval seconds have passed since +the last yield

        +
        + +
      • + +
      +

      Yield Parameters:

      +
        + +
      • + + task + + + + + + + — +

        a reference to the TimerTask instance so that the +block can control its own lifecycle. Necessary since self will +refer to the execution context of the block rather than the running +TimerTask.

        +
        + +
      • + +
      +

      Returns:

      +
        + +
      • + + + (TimerTask) + + + + — +

        the new TimerTask

        +
        + +
      • + +
      +

      Raises:

      +
        + +
      • + + + + + + + +

        ArgumentError when no block is given.

        +
        + +
      • + +
      + +
      + + + + +
      +
      +
      +
      +225
      +226
      +227
      +
      +
      # File 'lib/sidekiq_unique_jobs/timer_task.rb', line 225
      +
      +def self.execute(opts = {}, &task)
      +  TimerTask.new(opts, &task).execute
      +end
      +
      +
      + +
      + +
      +

      Instance Method Details

      + + +
      +

      + + #executeTimerTask + + + + + +

      +
      +

      Execute a previously created TimerTask.

      + + +
      +
      +
      + +
      +

      Examples:

      + + +

      Instance and execute in separate steps

      +

      + +
      task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" }
      +task.running? #=> false
      +task.execute
      +task.running? #=> true
      + + +

      Instance and execute in one line

      +

      + +
      task = Concurrent::TimerTask.new(execution_interval: 10){ print "Hello World\n" }.execute
      +task.running? #=> true
      + +
      + +

      Returns:

      +
        + +
      • + + + (TimerTask) + + + + — +

        a reference to self

        +
        + +
      • + +
      + +
      + + + + +
      +
      +
      +
      +208
      +209
      +210
      +211
      +212
      +213
      +214
      +215
      +216
      +
      +
      # File 'lib/sidekiq_unique_jobs/timer_task.rb', line 208
      +
      +def execute
      +  synchronize do
      +    if @running.false?
      +      @running.make_true
      +      schedule_next_task(@run_now ? 0 : @execution_interval)
      +    end
      +  end
      +  self
      +end
      +
      +
      + +
      +

      + + #running?Boolean + + + + + +

      +
      +

      Is the executor running?

      + + +
      +
      +
      + +

      Returns:

      +
        + +
      • + + + (Boolean) + + + + — +

        true when running, false when shutting down or shutdown

        +
        + +
      • + +
      + +
      + + + + +
      +
      +
      +
      +191
      +192
      +193
      +
      +
      # File 'lib/sidekiq_unique_jobs/timer_task.rb', line 191
      +
      +def running?
      +  @running.true?
      +end
      +
      +
      + +
      diff --git a/doc/SidekiqUniqueJobs/Timing.html b/doc/SidekiqUniqueJobs/Timing.html index 93cc60058..db5ba5d9e 100644 --- a/doc/SidekiqUniqueJobs/Timing.html +++ b/doc/SidekiqUniqueJobs/Timing.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Timing - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -76,7 +76,7 @@
      Included in:
      -
      Lock, Locksmith, OnConflict::Reject, OnConflict::Strategy, Redis::Entity
      +
      Lock, Locksmith, OnConflict::Reject, OnConflict::Strategy, Orphans::RubyReaper, Redis::Entity
      @@ -280,7 +280,7 @@

      # File 'lib/sidekiq_unique_jobs/timing.rb', line 50
       
       def clock_stamp
      -  if Process.const_defined?("CLOCK_MONOTONIC")
      +  if Process.const_defined?(:CLOCK_MONOTONIC)
           Process.clock_gettime(Process::CLOCK_MONOTONIC)
         else
           now_f
      @@ -466,9 +466,9 @@ 

      diff --git a/doc/SidekiqUniqueJobs/UniqueJobsError.html b/doc/SidekiqUniqueJobs/UniqueJobsError.html index 343496fbe..e7fddee51 100644 --- a/doc/SidekiqUniqueJobs/UniqueJobsError.html +++ b/doc/SidekiqUniqueJobs/UniqueJobsError.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::UniqueJobsError - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -143,9 +143,9 @@

      Direct Known Subclasses

      diff --git a/doc/SidekiqUniqueJobs/UnknownLock.html b/doc/SidekiqUniqueJobs/UnknownLock.html index 5a435ed6f..f409c4840 100644 --- a/doc/SidekiqUniqueJobs/UnknownLock.html +++ b/doc/SidekiqUniqueJobs/UnknownLock.html @@ -6,7 +6,7 @@ Exception: SidekiqUniqueJobs::UnknownLock - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -143,9 +143,9 @@

      Overview

      diff --git a/doc/SidekiqUniqueJobs/Unlockable.html b/doc/SidekiqUniqueJobs/Unlockable.html index 02b59ac67..f12c27423 100644 --- a/doc/SidekiqUniqueJobs/Unlockable.html +++ b/doc/SidekiqUniqueJobs/Unlockable.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Unlockable - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -478,9 +478,9 @@

      diff --git a/doc/SidekiqUniqueJobs/UpdateVersion.html b/doc/SidekiqUniqueJobs/UpdateVersion.html index 502f2d520..edf52d9f5 100644 --- a/doc/SidekiqUniqueJobs/UpdateVersion.html +++ b/doc/SidekiqUniqueJobs/UpdateVersion.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::UpdateVersion - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -248,9 +248,9 @@

      diff --git a/doc/SidekiqUniqueJobs/UpgradeLocks.html b/doc/SidekiqUniqueJobs/UpgradeLocks.html index 9f812e9f4..375962727 100644 --- a/doc/SidekiqUniqueJobs/UpgradeLocks.html +++ b/doc/SidekiqUniqueJobs/UpgradeLocks.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::UpgradeLocks - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -201,10 +201,10 @@

      %w[
      -  GRABBED
      -  AVAILABLE
      -  EXISTS
      -  VERSION
      +  GRABBED
      +  AVAILABLE
      +  EXISTS
      +  VERSION
       ].freeze

    @@ -536,7 +536,7 @@

  • - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -944,10 +944,10 @@

    log_info("Start - Upgrading Locks") - upgrade_v6_locks - delete_unused_v6_keys - delete_supporting_v6_keys - + # upgrade_v6_locks + # delete_unused_v6_keys + # delete_supporting_v6_keys + conn.hset(upgraded_key, version, now_f) log_info("Done - Upgrading Locks") end @@ -1334,7 +1334,7 @@

    - #redis(r_pool = nil, &block) ⇒ Sidekiq::RedisConnection, ConnectionPool + #redis(_r_pool = nil, &block) ⇒ Sidekiq::RedisConnection @@ -1360,7 +1360,7 @@

  • - (Sidekiq::RedisConnection, ConnectionPool) + (Sidekiq::RedisConnection) @@ -1464,9 +1464,9 @@

  • diff --git a/doc/SidekiqUniqueJobs/VersionCheck.html b/doc/SidekiqUniqueJobs/VersionCheck.html index 689652572..3872c4e2d 100644 --- a/doc/SidekiqUniqueJobs/VersionCheck.html +++ b/doc/SidekiqUniqueJobs/VersionCheck.html @@ -6,7 +6,7 @@ Class: SidekiqUniqueJobs::VersionCheck - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -810,9 +810,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Web.html b/doc/SidekiqUniqueJobs/Web.html index 8c0c1c8e4..2a5d8aff6 100644 --- a/doc/SidekiqUniqueJobs/Web.html +++ b/doc/SidekiqUniqueJobs/Web.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Web - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -153,7 +153,7 @@

    -

    rubocop:disable Metrics/MethodLength, Metrics/AbcSize.

    +

    rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.

  • @@ -179,7 +179,7 @@

    -

    rubocop:disable Metrics/MethodLength, Metrics/AbcSize

    +

    rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

    @@ -193,6 +193,7 @@

     
     
    +10
     11
     12
     13
    @@ -258,12 +259,29 @@ 

    73 74 75 -76

    +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93

    -
    # File 'lib/sidekiq_unique_jobs/web.rb', line 11
    +      
    # File 'lib/sidekiq_unique_jobs/web.rb', line 10
     
    -def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
    +def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
       app.helpers do
         include Web::Helpers
       end
    @@ -272,8 +290,8 @@ 

    @filter = params[:filter] || "*" @filter = "*" if @filter == "" @count = (params[:count] || 100).to_i - @current_cursor = params[:cursor] - @prev_cursor = params[:prev_cursor] + @current_cursor = params[:cursor].to_i + @prev_cursor = params[:prev_cursor].to_i @total_size, @next_cursor, @changelogs = changelog.page( cursor: @current_cursor, pattern: @filter, @@ -292,8 +310,8 @@

    @filter = params[:filter] || "*" @filter = "*" if @filter == "" @count = (params[:count] || 100).to_i - @current_cursor = params[:cursor] - @prev_cursor = params[:prev_cursor] + @current_cursor = params[:cursor].to_i + @prev_cursor = params[:prev_cursor].to_i @total_size, @next_cursor, @locks = digests.page( cursor: @current_cursor, @@ -304,8 +322,25 @@

    erb(unique_template(:locks)) end + app.get "/expiring_locks" do + @filter = params[:filter] || "*" + @filter = "*" if @filter == "" + @count = (params[:count] || 100).to_i + @current_cursor = params[:cursor].to_i + @prev_cursor = params[:prev_cursor].to_i + + @total_size, @next_cursor, @locks = expiring_digests.page( + cursor: @current_cursor, + pattern: @filter, + page_size: @count, + ) + + erb(unique_template(:locks)) + end + app.get "/locks/delete_all" do digests.delete_by_pattern("*", count: digests.count) + expiring_digests.delete_by_pattern("*", count: digests.count) redirect_to :locks end @@ -318,6 +353,7 @@

    app.get "/locks/:digest/delete" do digests.delete_by_digest(params[:digest]) + expiring_digests.delete_by_digest(params[:digest]) redirect_to :locks end @@ -339,9 +375,9 @@

    diff --git a/doc/SidekiqUniqueJobs/Web/Helpers.html b/doc/SidekiqUniqueJobs/Web/Helpers.html index 3038a46b6..0a8945947 100644 --- a/doc/SidekiqUniqueJobs/Web/Helpers.html +++ b/doc/SidekiqUniqueJobs/Web/Helpers.html @@ -6,7 +6,7 @@ Module: SidekiqUniqueJobs::Web::Helpers - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -190,7 +190,7 @@

    %w[
    -  filter count cursor prev_cursor poll direction
    +  filter count cursor prev_cursor poll direction
     ].freeze
    @@ -299,6 +299,29 @@

    Used to avoid incompatibility with older sidekiq versions.

    + + + +
  • + + + .expiring_digests ⇒ SidekiqUniqueJobs::ExpiringDigests + + + + + + + + + + + + + +

    The collection of digests.

    +
    +
  • @@ -538,6 +561,29 @@

    Used to avoid incompatibility with older sidekiq versions.

    + + + +
  • + + + #expiring_digests ⇒ SidekiqUniqueJobs::ExpiringDigests + + + + + + + + + + + + + +

    The collection of digests.

    +
    +
  • @@ -730,12 +776,12 @@

     
     
    -60
    -61
    -62
    +70 +71 +72

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 60
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 70
     
     def changelog
       @changelog ||= SidekiqUniqueJobs::Changelog.new
    @@ -806,25 +852,25 @@ 

     
     
    -71
    -72
    -73
    -74
    -75
    -76
    -77
    -78
    +81 +82 +83 +84 +85 +86 +87 +88

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 71
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 81
     
     def cparams(options)
       stringified_options = options.transform_keys(&:to_s)
    -  params.merge(stringified_options).map do |key, value|
    +  params.merge(stringified_options).filter_map do |key, value|
         next unless SAFE_CPARAMS.include?(key)
     
         "#{key}=#{CGI.escape(value.to_s)}"
    -  end.compact.join("&")
    +  end.join("&")
     end
    @@ -962,21 +1008,21 @@

     
     
    -89
    -90
    -91
    -92
    -93
    -94
    -95
    -96
    -97
    -98
     99
    -100
    +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 89
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 99
     
     def display_lock_args(args, truncate_after_chars = 2000)
       return "Invalid job payload, args is nil" if args.nil?
    @@ -993,6 +1039,63 @@ 

    + + +
    +

    + + .expiring_digestsSidekiqUniqueJobs::ExpiringDigests + + + + + +

    +
    +

    The collection of digests

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +60
    +61
    +62
    +
    +
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 60
    +
    +def expiring_digests
    +  @expiring_digests ||= SidekiqUniqueJobs::ExpiringDigests.new
    +end
    +
    @@ -1052,19 +1155,19 @@

     
     
    -151
    -152
    -153
    -154
    -155
    -156
    -157
    -158
    -159
    -160
    +163 +164 +165 +166 +167 +168 +169 +170 +171 +172

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 151
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 163
     
     def parse_time(time)
       case time
    @@ -1142,18 +1245,18 @@ 

     
     
    -109
    -110
    -111
    -112
    -113
    -114
    -115
    -116
    -117
    +119 +120 +121 +122 +123 +124 +125 +126 +127

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 109
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 119
     
     def redirect_to(subpath)
       if respond_to?(:to)
    @@ -1230,13 +1333,13 @@ 

     
     
    -126
    -127
    -128
    -129
    +136 +137 +138 +139

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 126
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 136
     
     def relative_time(time)
       stamp = time.getutc.iso8601
    @@ -1308,16 +1411,20 @@ 

     
     
    -138
    -139
    -140
    -141
    -142
    +148 +149 +150 +151 +152 +153 +154

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 138
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 148
     
     def safe_relative_time(time)
    +  return unless time
    +
       time = parse_time(time)
     
       relative_time(time)
    @@ -1472,7 +1579,7 @@ 

    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 29
     
     def unique_template(name)
    -  File.open(unique_filename(name)).read
    +  File.read(unique_filename(name))
     end
    @@ -1527,12 +1634,12 @@

     
     
    -60
    -61
    -62
    +70 +71 +72

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 60
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 70
     
     def changelog
       @changelog ||= SidekiqUniqueJobs::Changelog.new
    @@ -1603,25 +1710,25 @@ 

     
     
    -71
    -72
    -73
    -74
    -75
    -76
    -77
    -78
    +81 +82 +83 +84 +85 +86 +87 +88

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 71
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 81
     
     def cparams(options)
       stringified_options = options.transform_keys(&:to_s)
    -  params.merge(stringified_options).map do |key, value|
    +  params.merge(stringified_options).filter_map do |key, value|
         next unless SAFE_CPARAMS.include?(key)
     
         "#{key}=#{CGI.escape(value.to_s)}"
    -  end.compact.join("&")
    +  end.join("&")
     end
    @@ -1759,21 +1866,21 @@

     
     
    -89
    -90
    -91
    -92
    -93
    -94
    -95
    -96
    -97
    -98
     99
    -100
    +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 89
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 99
     
     def display_lock_args(args, truncate_after_chars = 2000)
       return "Invalid job payload, args is nil" if args.nil?
    @@ -1790,6 +1897,63 @@ 

    + + +
    +

    + + #expiring_digestsSidekiqUniqueJobs::ExpiringDigests + + + + + +

    +
    +

    The collection of digests

    + + +
    +
    +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +60
    +61
    +62
    +
    +
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 60
    +
    +def expiring_digests
    +  @expiring_digests ||= SidekiqUniqueJobs::ExpiringDigests.new
    +end
    +
    @@ -1849,19 +2013,19 @@

     
     
    -151
    -152
    -153
    -154
    -155
    -156
    -157
    -158
    -159
    -160
    +163 +164 +165 +166 +167 +168 +169 +170 +171 +172

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 151
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 163
     
     def parse_time(time)
       case time
    @@ -1939,18 +2103,18 @@ 

     
     
    -109
    -110
    -111
    -112
    -113
    -114
    -115
    -116
    -117
    +119 +120 +121 +122 +123 +124 +125 +126 +127

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 109
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 119
     
     def redirect_to(subpath)
       if respond_to?(:to)
    @@ -2027,13 +2191,13 @@ 

     
     
    -126
    -127
    -128
    -129
    +136 +137 +138 +139

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 126
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 136
     
     def relative_time(time)
       stamp = time.getutc.iso8601
    @@ -2105,16 +2269,20 @@ 

     
     
    -138
    -139
    -140
    -141
    -142
    +148 +149 +150 +151 +152 +153 +154

    -
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 138
    +      
    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 148
     
     def safe_relative_time(time)
    +  return unless time
    +
       time = parse_time(time)
     
       relative_time(time)
    @@ -2269,7 +2437,7 @@ 

    # File 'lib/sidekiq_unique_jobs/web/helpers.rb', line 29
     
     def unique_template(name)
    -  File.open(unique_filename(name)).read
    +  File.read(unique_filename(name))
     end
    @@ -2281,9 +2449,9 @@

    diff --git a/doc/_index.html b/doc/_index.html index 218addfe5..c7a9131ce 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -4,7 +4,7 @@ - Documentation by YARD 0.9.26 + Documentation by YARD 0.9.34 @@ -52,7 +52,7 @@
    -

    Documentation by YARD 0.9.26

    +

    Documentation by YARD 0.9.34

    Alphabetic Index

    @@ -142,6 +142,20 @@

    Namespace Listing A-Z

    +
  • + ClassMethods + + (Sidekiq::Worker::Overrides) + +
  • + +
  • + ClassMethods + + (SidekiqUniqueJobs::RedisScript::DSL) + +
  • +
  • Cli @@ -156,6 +170,13 @@

    Namespace Listing A-Z

  • +
  • + Client + + (SidekiqUniqueJobs::RedisScript) + +
  • +
  • ClientValidator @@ -170,6 +191,13 @@

    Namespace Listing A-Z

  • +
  • + Config + + (SidekiqUniqueJobs::RedisScript) + +
  • +
  • Conflict @@ -192,6 +220,13 @@

    Namespace Listing A-Z

  • D
    • +
    • + DSL + + (SidekiqUniqueJobs::RedisScript) + +
    • +
    • Deprecation @@ -235,6 +270,13 @@

      Namespace Listing A-Z

    • +
    • + ExpiringDigests + + (SidekiqUniqueJobs) + +
    • +
    @@ -244,14 +286,14 @@

    Namespace Listing A-Z

    • - Hash + Hash + + (SidekiqUniqueJobs::Redis)
    • - Hash - - (SidekiqUniqueJobs::Redis) + Hash
    • @@ -317,16 +359,16 @@

      Namespace Listing A-Z

    • - Job + Job - (Sidekiq) + (SidekiqUniqueJobs)
    • - Job + Job - (SidekiqUniqueJobs) + (Sidekiq)
    • @@ -423,6 +465,13 @@

      Namespace Listing A-Z

      +
    • + LockType + + (SidekiqUniqueJobs) + +
    • +
    • Locksmith @@ -437,6 +486,13 @@

      Namespace Listing A-Z

    • +
    • + Logging + + (SidekiqUniqueJobs::RedisScript) + +
    • +
    • Logging @@ -444,6 +500,13 @@

      Namespace Listing A-Z

    • +
    • + LuaError + + (SidekiqUniqueJobs::RedisScript) + +
    • +
    • LuaReaper @@ -473,6 +536,13 @@

      Namespace Listing A-Z

    • +
    • + Middleware + + (SidekiqUniqueJobs::Logging) + +
    • +
    • Middleware @@ -481,9 +551,9 @@

      Namespace Listing A-Z

    • - Middleware + Misconfiguration - (SidekiqUniqueJobs::Logging) + (SidekiqUniqueJobs::RedisScript)
    • @@ -638,6 +708,13 @@

      Namespace Listing A-Z

      +
    • + RedisScript + + (SidekiqUniqueJobs) + +
    • +
    • Reflectable @@ -698,6 +775,13 @@

      Namespace Listing A-Z

    • +
    • + Script + + (SidekiqUniqueJobs::RedisScript) + +
    • +
    • Script @@ -706,9 +790,9 @@

      Namespace Listing A-Z

    • - Server + Scripts - (SidekiqUniqueJobs::Middleware) + (SidekiqUniqueJobs::RedisScript)
    • @@ -719,6 +803,13 @@

      Namespace Listing A-Z

      +
    • + Server + + (SidekiqUniqueJobs::Middleware) + +
    • +
    • ServerValidator @@ -750,6 +841,13 @@

      Namespace Listing A-Z

    • +
    • + SignletonOverrides + + (Sidekiq::Worker) + +
    • +
    • SortedEntry @@ -786,6 +884,13 @@

      Namespace Listing A-Z

    • T
      • +
      • + Template + + (SidekiqUniqueJobs::RedisScript) + +
      • +
      • TimerTask @@ -800,6 +905,13 @@

        Namespace Listing A-Z

      • +
      • + Timing + + (SidekiqUniqueJobs::RedisScript) + +
      • +
    @@ -809,44 +921,44 @@

    Namespace Listing A-Z

    diff --git a/doc/class_list.html b/doc/class_list.html index 26ca41cc1..6fa6f406d 100644 --- a/doc/class_list.html +++ b/doc/class_list.html @@ -43,7 +43,7 @@

    Class List

    diff --git a/doc/file.CHANGELOG.html b/doc/file.CHANGELOG.html index 67f59b979..49624d9f7 100644 --- a/doc/file.CHANGELOG.html +++ b/doc/file.CHANGELOG.html @@ -6,7 +6,7 @@ File: CHANGELOG - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -59,6 +59,534 @@

    Changelog

    +

    v8.0.5 (2023-11-11)

    + +

    Full Changelog

    + +

    Merged pull requests:

    + +
      +
    • Bump @babel/traverse from 7.22.8 to 7.23.3 in /myapp #819 (dependabot[bot])
    • +
    • Bump postcss from 8.4.21 to 8.4.31 in /myapp #811 (dependabot[bot])
    • +
    • fix: while_executing should not invoke conflict strategy when the job was successfully executed [v8] #810 (cuzik)
    • +
    • Bump actions/checkout from 3 to 4 #808 (dependabot[bot])
    • +
    • Bump semver from 6.3.0 to 6.3.1 in /myapp #798 (dependabot[bot])
    • +
    • Because replace is a client strategy, it should only remove client locks aka queue locks. #778 (bigzed)
    • +
    + +

    v8.0.4 (2023-11-11)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Fixed bugs:

    + +
      +
    • Sidekiq 7: Unsupported command argument type: TrueClass #816
    • +
    • fix(web): don't show bogus lock digests #804 (Earlopain)
    • +
    + +

    Closed issues:

    + +
      +
    • register_reaper_process nx: true crash Sidekiq on startup #817
    • +
    • Should client middleware also be added to the Sidekiq server config? #803
    • +
    • 8.0.1 Time on locks & changelog UI is incorrect/wrong #761
    • +
    • Job executed twice when reaper runs #738
    • +
    + +

    Merged pull requests:

    + +
      +
    • fix: Sidekiq 7.2 throws TypeError: Unsupported command argument type: TrueClass when using byscore: true #815 (Amnesthesia)
    • +
    • Add sidekiq_option for on-conflict-reschedule perform_in time #813 (mgmarlow)
    • +
    • Handle strategy fallbacks properly #809 (matejrisek)
    • +
    • Fix CI status badge #802 (tagliala)
    • +
    + +

    v7.1.30 (2023-07-17)

    + +

    Full Changelog

    + +

    Closed issues:

    + +
      +
    • Release new gem version with "fix replace deprecated rpoplpush w/lmove" #795
    • +
    • Redis has deprecated the rpoplpushcommand #793
    • +
    • Deprecation Warning: Use of rpoplpush command in Redis #792
    • +
    • Logging::Middleware.context can include empty string as key when lock is not set in job hash #785
    • +
    + +

    v8.0.3 (2023-05-27)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Fixed bugs:

    + + + +

    Closed issues:

    + +
      +
    • unlocked reflection is never called #782
    • +
    • Migrate away from deprecated Redis commands #780
    • +
    • while_executing with on_conflict: :reschedule reschedules job when unlock fails #770
    • +
    • Redis server v6.0 compatibility #769
    • +
    • Locks not removed after worker finishes #758
    • +
    + +

    Merged pull requests:

    + +
      +
    • Add lock to item when lock_type is pulled from Job class sidekiq options #786 (ttstarck)
    • +
    • Fix rubocop failure by expecting array to be empty #784 (GabrielaGuedes)
    • +
    • fix(doc): improve information on unlock_failed #776 (mhenrixon)
    • +
    + +

    v8.0.2 (2023-03-13)

    + +

    Full Changelog

    + +

    Closed issues:

    + +
      +
    • Missing v7.1 branch? #757
    • +
    • Allow one running job but at most one job in the queue #748
    • +
    + +

    Merged pull requests:

    + + + +

    v8.0.1 (2023-02-14)

    + +

    Full Changelog

    + +

    Closed issues:

    + +
      +
    • TypeError: Unsupported command argument type: ActiveSupport::Duration #754
    • +
    • Incompatibility with Sidekiq 7 #736
    • +
    + +

    Merged pull requests:

    + +
      +
    • Fix active worker detection by using correct keys #756 (dodo121)
    • +
    • Fix minor typo in drift_reaper_interval comment #755 (lazyatom)
    • +
    + +

    v8.0.0 (2023-01-30)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Closed issues:

    + +
      +
    • Support for redis 5 #752
    • +
    • while_executing jobs being dropped #749
    • +
    + +

    Merged pull requests:

    + +
      +
    • fix: backport the fix for the return value of #deep_transform_keys #750 (fixtheclouds)
    • +
    + +

    v7.1.29 (2022-12-03)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + + + +

    Merged pull requests:

    + + + +

    v7.1.28 (2022-11-28)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + +
      +
    • Unique Jobs Not Running with Version 7.1.26 #730
    • +
    + +

    Closed issues:

    + +
      +
    • Error "undefined method `redis_info' for Sidekiq:Module" on upgrade #740
    • +
    • spammed by Nothing to delete; exiting during spec #733
    • +
    + +

    Merged pull requests:

    + + + +

    v7.1.27 (2022-07-30)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Fixed bugs:

    + +
      +
    • Fix(namespace): Prevent self-conflict when redis-namespace is present #732 (mhenrixon)
    • +
    + +

    Closed issues:

    + +
      +
    • Disable logging in Rails testing #727
    • +
    • Memory bloat / dangling keys / reaper not cleaning orphans #637
    • +
    + +

    v7.1.26 (2022-07-28)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + +
      +
    • Fix(until_expired): Fix test and implementation #725 (mhenrixon)
    • +
    + +

    Fixed bugs:

    + +
      +
    • Fix(until_and_while_executing): Improve timeouts slightly #728 (mhenrixon)
    • +
    • Fix(unlock): Delete primed keys on last entry #726 (mhenrixon)
    • +
    + +

    Merged pull requests:

    + + + +

    v7.1.25 (2022-06-13)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + + + +

    v7.1.24 (2022-06-09)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Merged pull requests:

    + +
      +
    • Use sidekiq/testing Worker.clear API in sidekiq_unique_jobs/testing #713 (dsander)
    • +
    + +

    v7.1.23 (2022-05-23)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + + + +

    v7.1.22 (2022-05-04)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + +
      +
    • Failed jobs waiting to be retried are not considered when fetching uniqueness #394
    • +
    • fix(locksmith): execute to yield without arguments #710 (mhenrixon)
    • +
    • fix: re:lock until_executing on worker failure #709 (mhenrixon)
    • +
    + +

    Closed issues:

    + +
      +
    • Reviwing: Failed jobs waiting to be retried are not considered when fetching uniqueness #708
    • +
    + +

    v7.1.21 (2022-04-23)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Closed issues:

    + +
      +
    • DEPRECATION WARNING: default_worker_options is deprecated and will be removed from Sidekiq 7.0 (use default_job_options instead) (called from notify_agents at /Users/hackeron/Development/Tether/timeline/app/models/user.rb:303) #705
    • +
    + +

    v7.1.20 (2022-04-22)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Merged pull requests:

    + +
      +
    • improve README wrt. middleware config #704 (slhck)
    • +
    + +

    v7.1.19 (2022-04-09)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + +
      +
    • concurrent-ruby 1.1.10 spikes volume of jobs #701
    • +
    • Reimplement the entire TimerTask as it was #702 (mhenrixon)
    • +
    + +

    v7.1.18 (2022-04-05)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    v7.1.17 (2022-04-05)

    + +

    Full Changelog

    + +

    v7.1.16 (2022-04-02)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Fixed bugs:

    + + + +

    Closed issues:

    + +
      +
    • concurrent-ruby has dropped support for TimerTask timeouts #697
    • +
    • Most recent changelogs are removed first #696
    • +
    • Improve README slightly #694
    • +
    • locksmith.rb:327: NoMethodError: undefined method `+' for nil:NilClass #686
    • +
    • lock_timeout cannot be nil #675
    • +
    • Skip reaping when queues are too large #670
    • +
    + +

    Merged pull requests:

    + + + +

    v7.1.15 (2022-02-10)

    + +

    Full Changelog

    + +

    Merged pull requests:

    + +
      +
    • Fixing reschedule when using a non default queue #679 (bigzed)
    • +
    + +

    v7.1.14 (2022-02-04)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    v7.1.13 (2022-02-03)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + + + +

    Fixed bugs:

    + + + +

    Closed issues:

    + +
      +
    • Job finished, but lock is not cleared #677
    • +
    • sidekiq_options lock conflicts with sidekiq-lock gem lock option #669
    • +
    • Slow evalsha causing timeouts #668
    • +
    • Inconsistent documentation for config validation #647
    • +
    + +

    Merged pull requests:

    + + + +

    v7.1.12 (2021-12-01)

    + +

    Full Changelog

    + +

    Implemented enhancements:

    + +
      +
    • Improve Ruby Reaper performance under heavy load #663
    • +
    • Improve reaper performance under heavy load #666 (mhenrixon)
    • +
    + +

    v7.1.11 (2021-11-30)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + + + +

    Closed issues:

    + +
      +
    • Question: Wait instead of cancelling if it is executing? #655
    • +
    • Expired Locks remain in zset of digests [using "until_expired" lock] #653
    • +
    • [Q&A] Performance & Dead Locks #652
    • +
    • Sidekiq 6.3.0 includes Job module that clashes with sidekiq_unique_ext.rb class Job #651
    • +
    + +

    v7.1.10 (2021-10-18)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + +
      +
    • "IndexError: string not matched" when job is replaced on client #635
    • +
    + +

    Merged pull requests:

    + +
      +
    • Update URL for Sidekiq's Enterprise unique jobs #648 (jsantos)
    • +
    + +

    v7.1.8 (2021-10-08)

    + +

    Full Changelog

    + +

    Fixed bugs:

    + +
      +
    • undefined method delete' for classSidekiq::Job' #634
    • +
    • INFO keys not persisted when job is enqueued #602
    • +
    • lock_info set to true but no lock info showing up in web ui #589
    • +
    • Prevent too eager cleanup of lock info #645 (mhenrixon)
    • +
    + +

    Closed issues:

    + +
      +
    • Compatibility with unreleased Sidekiq 6.3.0 #636
    • +
    + +

    Merged pull requests:

    + + +

    v7.0.13 (2021-09-27)

    Full Changelog

    @@ -174,7 +702,7 @@

    #611 (mhenrixon) -
  • Start new orphan reaper process if orphan reaper is not running #604 (Assa1121)
  • +
  • Start new orphan reaper process if orphan reaper is not running #604 (AlexFlint73)
  • Fixed bugs:

    @@ -362,7 +890,6 @@

    #464
  • Jobs executing and immediately returning #418
  • until_and_while_executing + sidekiq retry mechanism #395
  • -
  • Failed jobs waiting to be retried are not considered when fetching uniqueness #394
  • Fix that :PRIMED keys are seemingly not removed #574 (mhenrixon)
  • @@ -2171,9 +2698,9 @@

    - Generated on Mon Sep 27 15:29:05 2021 by - yard - 0.9.26 (ruby-3.0.2). + Generated on Wed Jan 24 10:57:22 2024 by + yard + 0.9.34 (ruby-3.3.0).

    diff --git a/doc/file.LICENSE.html b/doc/file.LICENSE.html index dd3c866a9..37125a964 100644 --- a/doc/file.LICENSE.html +++ b/doc/file.LICENSE.html @@ -6,7 +6,7 @@ File: LICENSE - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -60,9 +60,9 @@
    The MIT License (MIT)

    Copyright (c) 2017 Mikael Henriksson

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
    diff --git a/doc/file.README.html b/doc/file.README.html index 22981db5d..7de7016dd 100644 --- a/doc/file.README.html +++ b/doc/file.README.html @@ -6,7 +6,7 @@ File: README - — Documentation by YARD 0.9.26 + — Documentation by YARD 0.9.34 @@ -59,7 +59,7 @@

    SidekiqUniqueJobs

    -

    Join the chat at https://gitter.im/mhenrixon/sidekiq-unique-jobs Build Status Code Climate Test Coverage

    +

    Join the chat at https://gitter.im/mhenrixon/sidekiq-unique-jobs Build Status Code Climate Test Coverage

    Support Me

    @@ -99,7 +99,7 @@

    Support Me

  • raise
  • reject
  • replace
  • -
  • Reschedule
  • +
  • reschedule
  • Custom Strategies
  • 3 Cleanup Dead Locks
  • @@ -169,7 +169,7 @@

    Introduction

    This gem adds unique constraints to sidekiq jobs. The uniqueness is achieved by creating a set of keys in redis based off of queue, class, args (in the sidekiq job hash).

    -

    By default, only one lock for a given hash can be acquired. What happens when a lock can't be acquired is governed by a chosen Conflict Strategy strategy. Unless a conflict strategy is chosen

    +

    By default, only one lock for a given hash can be acquired. What happens when a lock can't be acquired is governed by a chosen Conflict Strategy strategy. Unless a conflict strategy is chosen (?)

    This is the documentation for the main branch. You can find the documentation for each release by navigating to its tag.

    @@ -202,9 +202,11 @@

    Add the middleware

    NOTE if you want to use the reaper you also need to configure the server middleware.

    -

    A full example

    +

    The following shows how to modify your config/initializers/sidekiq.rb file to use the middleware. Here is a full example.

    -
    Sidekiq.configure_server do |config|
    +
    require "sidekiq-unique-jobs"
    +
    +Sidekiq.configure_server do |config|
       config.redis = { url: ENV["REDIS_URL"], driver: :hiredis }
     
       config.client_middleware do |chain|
    @@ -229,15 +231,14 @@ 

    Add the middleware

    Your first worker

    -

    The most likely to be used worker is :until_executed. This type of lock creates a lock from when UntilExecutedWorker.perform_async is called until right after UntilExecutedWorker.new.perform has been called.

    +

    The lock type most likely to be is :until_executed. This type of lock creates a lock from when UntilExecutedWorker.perform_async is called until right after UntilExecutedWorker.new.perform has been called.

    # frozen_string_literal: true
     
     class UntilExecutedWorker
       include Sidekiq::Worker
     
    -  sidekiq_options queue: :until_executed,
    -                  lock: :until_executed
    +  sidekiq_options lock: :until_executed
     
       def perform
         logger.info("cowboy")
    @@ -420,9 +421,9 @@ 

    Custom Locks

    Conflict Strategy

    -

    Decides how we handle conflict. We can either reject the job to the dead queue or reschedule it. Both are useful for jobs that absolutely need to run and have been configured to use the lock WhileExecuting that is used only by the sidekiq server process.

    +

    Decides how we handle conflict. We can either reject the job to the dead queue or reschedule it. Both are useful for jobs that absolutely need to run and have been configured to use the lock WhileExecuting that is used only by the sidekiq server process.

    -

    The last one is log which can be be used with the lock UntilExecuted and UntilExpired. Now we write a log entry saying the job could not be pushed because it is a duplicate of another job with the same arguments.

    +

    Furthermore, log can be be used with the lock UntilExecuted and UntilExpired. Now we write a log entry saying the job could not be pushed because it is a duplicate of another job with the same arguments.

    It is possible for locks to have different conflict strategy for the client and server. This is useful for :until_and_while_executing.

    @@ -435,7 +436,7 @@

    log

    sidekiq_options on_conflict: :log
     
    -

    This strategy is intended to be used with UntilExecuted and UntilExpired. It will log a line about that this is job is a duplicate of another.

    +

    This strategy is intended to be used with UntilExecuted and UntilExpired. It will log a line that this job is a duplicate of another.

    raise

    @@ -463,7 +464,7 @@

    replace

    This is slightly dangerous and should probably only be used for jobs that are always scheduled in the future. Currently only attempting to retry one time.

    -

    Reschedule

    +

    reschedule

    sidekiq_options on_conflict: :reschedule
     
    @@ -605,23 +606,23 @@

    timeout

    This is also mostly useful for reporting/metrics purposes. What this reflection does is signal that the job was configured to wait (lock_timeout was configured), but we couldn't retrieve a lock even though we waited for some time.

    -

    unlock_failed

    +

    unlock_failed

    -

    This is not got, this is worth

    +

    This means that the server middleware could not unlock your job and the lock is kept (potentially preventing subsequent jobs from being pushed or processed).

    -

    unlocked

    +

    unlocked

    Also mostly useful for reporting purposes. The job was successfully unlocked.

    -

    unknown_sidekiq_worker

    +

    unknown_sidekiq_worker

    The reason this happens is that the server couldn't find a valid sidekiq worker class. Most likely, that worker isn't intended to be processed by this sidekiq server instance.

    -

    Show Locks

    +

    Show Locks

    Locks

    -

    Show Lock

    +

    Show Lock

    Lock

    @@ -629,7 +630,7 @@

    Testing

    Validating Worker Configuration

    -

    Since v7 it is possible to perform some simple validation against your workers sidekiq_options. What it does is scan for some issues that are known to cause problems in production.

    +

    Since v7 it is possible to perform some simple validation against your workers sidekiq_options. What it does is scan for some issues that are known to cause problems in production.

    Let's take a bad worker:

    @@ -657,15 +658,16 @@

    Validating Worker Configuration

    If you are not using RSpec (a lot of people prefer minitest or test unit) you can do something like:

    -
    assert SidekiqUniqueJobs.validate_worker!(BadWorker.get_sidekiq_options)
    +
    assert_raise(InvalidWorker){ SidekiqUniqueJobs.validate_worker!(BadWorker.get_sidekiq_options) }
     

    Uniqueness

    -

    This has been probably the most confusing part of this gem. People get really confused with how unreliable the unique jobs have been. I there for decided to do what Mike is doing for sidekiq enterprise. Read the section about unique jobs: Enterprise unique jobs

    +

    This has been probably the most confusing part of this gem. People get really confused with how unreliable the unique jobs have been. I there for decided to do what Mike is doing for sidekiq enterprise. Read the section about unique jobs: Enterprise unique jobs(?)

    SidekiqUniqueJobs.configure do |config|
       config.enabled = !Rails.env.test?
    +  config.logger_enabled = !Rails.env.test?
     end
     
    @@ -789,6 +791,7 @@

    Global Configuration

    SidekiqUniqueJobs.configure do |config|
       config.logger = Sidekiq.logger # default, change at your own discretion
    +  config.logger_enabled  = true # default, disable for test environments
       config.debug_lua       = false # Turn on when debugging
       config.lock_info       = false # Turn on when debugging
       config.lock_ttl        = 600   # Expire locks after 10 minutes
    @@ -1081,9 +1084,9 @@ 

    Contributors

    diff --git a/doc/frames.html b/doc/frames.html index 1310783d8..4f918f573 100644 --- a/doc/frames.html +++ b/doc/frames.html @@ -2,7 +2,7 @@ - Documentation by YARD 0.9.26 + Documentation by YARD 0.9.34