Class: SidekiqUniqueJobs::Orphans::Reaper
- Inherits:
-
Object
- Object
- SidekiqUniqueJobs::Orphans::Reaper
- Includes:
- Connection, JSON, Logging, Script::Caller
- Defined in:
- lib/sidekiq_unique_jobs/orphans/reaper.rb
Overview
this is a much slower version of the lua script but does not crash redis
Class DeleteOrphans provides deletion of orphaned digests
Direct Known Subclasses
Constant Summary collapse
- REAPERS =
Returns Hash<Symbol, SidekiqUniqueJobs::Orphans::Reaper] the current implementation of reapers.
{ lua: SidekiqUniqueJobs::Orphans::LuaReaper, ruby: SidekiqUniqueJobs::Orphans::RubyReaper, none: SidekiqUniqueJobs::Orphans::NullReaper, nil => SidekiqUniqueJobs::Orphans::NullReaper, false => SidekiqUniqueJobs::Orphans::NullReaper, }.freeze
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Class Method Summary collapse
-
.call(conn = nil) ⇒ void
Execute deletion of orphaned digests.
Instance Method Summary collapse
-
#call ⇒ Integer
Delete orphaned digests.
-
#config ⇒ SidekiqUniqueJobs::Config
Convenient access to the global configuration.
-
#initialize(conn) ⇒ Reaper
constructor
Initialize a new instance of DeleteOrphans.
-
#reaper ⇒ Symbol
The reaper that was configured.
-
#reaper_count ⇒ Integer
The number of locks to reap at a time.
-
#reaper_timeout ⇒ Integer
The configured timeout for the reaper.
Methods included from JSON
dump_json, load_json, safe_load_json
Methods included from Logging
#build_message, included, #log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context, #with_configured_loggers_context, #with_logging_context
Methods included from Script::Caller
call_script, debug_lua, do_call, extract_args, max_history, normalize_argv, now_f, redis_version
Methods included from Connection
Constructor Details
#initialize(conn) ⇒ Reaper
Initialize a new instance of DeleteOrphans
55 56 57 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 55 def initialize(conn) @conn = conn end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
48 49 50 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 48 def conn @conn end |
Class Method Details
.call(conn = nil) ⇒ void
This method returns an undefined value.
Execute deletion of orphaned digests
39 40 41 42 43 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 39 def self.call(conn = nil) return new(conn).call if conn redis { |rcon| new(rcon).call } end |
Instance Method Details
#call ⇒ Integer
Delete orphaned digests
105 106 107 108 109 110 111 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 105 def call if (implementation = REAPERS[reaper]) implementation.new(conn).call else log_fatal(":#{reaper} is invalid for `SidekiqUnqiueJobs.config.reaper`") end end |
#config ⇒ SidekiqUniqueJobs::Config
Convenient access to the global configuration
65 66 67 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 65 def config SidekiqUniqueJobs.config end |
#reaper ⇒ Symbol
The reaper that was configured
75 76 77 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 75 def reaper config.reaper end |
#reaper_count ⇒ Integer
The number of locks to reap at a time
95 96 97 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 95 def reaper_count config.reaper_count end |
#reaper_timeout ⇒ Integer
The configured timeout for the reaper
85 86 87 |
# File 'lib/sidekiq_unique_jobs/orphans/reaper.rb', line 85 def reaper_timeout config.reaper_timeout end |