doc/SidekiqUniqueJobs/Orphans/RubyReaper.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: SidekiqUniqueJobs::Orphans::RubyReaper
— Documentation by YARD 0.9.26
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "SidekiqUniqueJobs::Orphans::RubyReaper";
relpath = '../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../_index.html">Index (R)</a> »
<span class='title'><span class='object_link'><a href="../../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span> » <span class='title'><span class='object_link'><a href="../Orphans.html" title="SidekiqUniqueJobs::Orphans (module)">Orphans</a></span></span>
»
<span class="title">RubyReaper</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: SidekiqUniqueJobs::Orphans::RubyReaper
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName"><span class='object_link'><a href="Reaper.html" title="SidekiqUniqueJobs::Orphans::Reaper (class)">Reaper</a></span></span>
<ul class="fullTree">
<li>Object</li>
<li class="next"><span class='object_link'><a href="Reaper.html" title="SidekiqUniqueJobs::Orphans::Reaper (class)">Reaper</a></span></li>
<li class="next">SidekiqUniqueJobs::Orphans::RubyReaper</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<div class="note notetag">
<strong>Note:</strong>
<div class='inline'><p>this is a much slower version of the lua script but does not crash redis</p>
</div>
</div>
<p>Class DeleteOrphans provides deletion of orphaned digests</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Author:</p>
<ul class="author">
<li>
<div class='inline'><p>Mikael Henriksson <a href="mailto:mikael@mhenrixon.com">mikael@mhenrixon.com</a></p>
</div>
</li>
</ul>
</div>
<h2>
Constant Summary
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
</h2>
<dl class="constants">
<dt id="RUN_SUFFIX-constant" class="">RUN_SUFFIX =
<div class="docstring">
<div class="discussion">
<p>Returns the suffix for :RUN locks.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>the suffix for :RUN locks</p>
</div>
</li>
</ul>
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>:RUN</span><span class='tstring_end'>"</span></span></pre></dd>
</dl>
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#digests-instance_method" title="#digests (instance method)">#<strong>digests</strong> ⇒ Object </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute digests.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#retried-instance_method" title="#retried (instance method)">#<strong>retried</strong> ⇒ Object </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute retried.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#scheduled-instance_method" title="#scheduled (instance method)">#<strong>scheduled</strong> ⇒ Object </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute scheduled.</p>
</div></span>
</li>
</ul>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#active%3F-instance_method" title="#active? (instance method)">#<strong>active?</strong>(digest) ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#belongs_to_job%3F-instance_method" title="#belongs_to_job? (instance method)">#<strong>belongs_to_job?</strong>(digest) ⇒ true, false </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the digest has a matching job.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong> ⇒ Integer </a>
</span>
<span class="summary_desc"><div class='inline'><p>Delete orphaned digests.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#considered_active%3F-instance_method" title="#considered_active? (instance method)">#<strong>considered_active?</strong>(time_f) ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#enqueued%3F-instance_method" title="#enqueued? (instance method)">#<strong>enqueued?</strong>(digest) ⇒ true </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the digest exists in a Sidekiq::Queue.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#entries-instance_method" title="#entries (instance method)">#<strong>entries</strong>(conn, queue, &block) ⇒ Object </a>
</span>
<span class="summary_desc"><div class='inline'><p>rubocop:disable Metrics/MethodLength.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#in_sorted_set%3F-instance_method" title="#in_sorted_set? (instance method)">#<strong>in_sorted_set?</strong>(key, digest) ⇒ true, false </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks a sorted set for the existance of this digest.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(conn) ⇒ RubyReaper </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'><p>Initialize a new instance of DeleteOrphans.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#match%3F-instance_method" title="#match? (instance method)">#<strong>match?</strong>(key_one, key_two) ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#orphans-instance_method" title="#orphans (instance method)">#<strong>orphans</strong> ⇒ Array<String> </a>
</span>
<span class="summary_desc"><div class='inline'><p>Find orphaned digests.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#queues-instance_method" title="#queues (instance method)">#<strong>queues</strong>(conn) { ... } ⇒ void </a>
</span>
<span class="summary_desc"><div class='inline'><p>Loops through all the redis queues and yields them one by one.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#retried%3F-instance_method" title="#retried? (instance method)">#<strong>retried?</strong>(digest) ⇒ true </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the digest exists in the Sidekiq::RetrySet.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#scheduled%3F-instance_method" title="#scheduled? (instance method)">#<strong>scheduled?</strong>(digest) ⇒ true </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the digest exists in the Sidekiq::ScheduledSet.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(conn) ⇒ <tt><span class='object_link'><a href="" title="SidekiqUniqueJobs::Orphans::RubyReaper (class)">RubyReaper</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Initialize a new instance of DeleteOrphans</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>conn</span>
<span class='type'>(<tt><span class='object_link'><a href="../Redis.html" title="SidekiqUniqueJobs::Redis (module)">Redis</a></span></tt>)</span>
—
<div class='inline'><p>a connection to redis</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
34
35
36
37
38
39</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 34</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_conn'>conn</span><span class='rparen'>)</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_conn'>conn</span><span class='rparen'>)</span>
<span class='ivar'>@digests</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Digests.html" title="SidekiqUniqueJobs::Digests (class)">Digests</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Digests.html#initialize-instance_method" title="SidekiqUniqueJobs::Digests#initialize (method)">new</a></span></span>
<span class='ivar'>@scheduled</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Redis.html" title="SidekiqUniqueJobs::Redis (module)">Redis</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Redis/SortedSet.html" title="SidekiqUniqueJobs::Redis::SortedSet (class)">SortedSet</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Redis/Entity.html#initialize-instance_method" title="SidekiqUniqueJobs::Redis::Entity#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#SCHEDULE-constant" title="SidekiqUniqueJobs::SCHEDULE (constant)">SCHEDULE</a></span></span><span class='rparen'>)</span>
<span class='ivar'>@retried</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Redis.html" title="SidekiqUniqueJobs::Redis (module)">Redis</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Redis/SortedSet.html" title="SidekiqUniqueJobs::Redis::SortedSet (class)">SortedSet</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Redis/Entity.html#initialize-instance_method" title="SidekiqUniqueJobs::Redis::Entity#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#RETRY-constant" title="SidekiqUniqueJobs::RETRY (constant)">RETRY</a></span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id=""></span>
<div class="method_details first">
<h3 class="signature first" id="digests-instance_method">
#<strong>digests</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute digests.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
19
20
21</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 19</span>
<span class='kw'>def</span> <span class='id identifier rubyid_digests'>digests</span>
<span class='ivar'>@digests</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id=""></span>
<div class="method_details ">
<h3 class="signature " id="retried-instance_method">
#<strong>retried</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute retried.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
27
28
29</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 27</span>
<span class='kw'>def</span> <span class='id identifier rubyid_retried'>retried</span>
<span class='ivar'>@retried</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id=""></span>
<div class="method_details ">
<h3 class="signature " id="scheduled-instance_method">
#<strong>scheduled</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute scheduled.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
23
24
25</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 23</span>
<span class='kw'>def</span> <span class='id identifier rubyid_scheduled'>scheduled</span>
<span class='ivar'>@scheduled</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="active?-instance_method">
#<strong>active?</strong>(digest) ⇒ <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
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</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 123</span>
<span class='kw'>def</span> <span class='id identifier rubyid_active?'>active?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
</span> <span class='const'><span class='object_link'><a href="../../Sidekiq.html" title="Sidekiq (module)">Sidekiq</a></span></span><span class='period'>.</span><span class='id identifier rubyid_redis'>redis</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span>
<span class='id identifier rubyid_procs'>procs</span> <span class='op'>=</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_sscan_each'>sscan_each</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>processes</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_procs'>procs</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='id identifier rubyid_procs'>procs</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
<span class='id identifier rubyid_valid'>valid</span><span class='comma'>,</span> <span class='id identifier rubyid_workers'>workers</span> <span class='op'>=</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_pipelined'>pipelined</span> <span class='kw'>do</span>
<span class='comment'># TODO: Remove the if statement in the future
</span> <span class='kw'>if</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:exists?</span><span class='rparen'>)</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_exists'>exists</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_hgetall'>hgetall</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>:workers</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_valid'>valid</span>
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_workers'>workers</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
<span class='id identifier rubyid_workers'>workers</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid__tid'>_tid</span><span class='comma'>,</span> <span class='id identifier rubyid_job'>job</span><span class='op'>|</span>
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='lparen'>(</span><span class='id identifier rubyid_item'>item</span> <span class='op'>=</span> <span class='id identifier rubyid_safe_load_json'>safe_load_json</span><span class='lparen'>(</span><span class='id identifier rubyid_job'>job</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_payload'>payload</span> <span class='op'>=</span> <span class='id identifier rubyid_safe_load_json'>safe_load_json</span><span class='lparen'>(</span><span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#PAYLOAD-constant" title="SidekiqUniqueJobs::PAYLOAD (constant)">PAYLOAD</a></span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#LOCK_DIGEST-constant" title="SidekiqUniqueJobs::LOCK_DIGEST (constant)">LOCK_DIGEST</a></span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_considered_active?'>considered_active?</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='lbracket'>[</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#CREATED_AT-constant" title="SidekiqUniqueJobs::CREATED_AT (constant)">CREATED_AT</a></span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>false</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="belongs_to_job?-instance_method">
#<strong>belongs_to_job?</strong>(digest) ⇒ <tt>true</tt>, <tt>false</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the digest has a matching job.</p>
<ol>
<li>It checks the scheduled set</li>
<li>It checks the retry set</li>
<li>It goes through all queues</li>
</ol>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>digest</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>the digest to search for</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>)</span>
—
<div class='inline'><p>when either of the checks return true</p>
</div>
</li>
<li>
<span class='type'>(<tt>false</tt>)</span>
—
<div class='inline'><p>when no job was found for this digest</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
78
79
80</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 78</span>
<span class='kw'>def</span> <span class='id identifier rubyid_belongs_to_job?'>belongs_to_job?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='id identifier rubyid_scheduled?'>scheduled?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_retried?'>retried?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_enqueued?'>enqueued?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_active?'>active?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="call-instance_method">
#<strong>call</strong> ⇒ <tt>Integer</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Delete orphaned digests</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
—
<div class='inline'><p>the number of reaped locks</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
47
48
49</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 47</span>
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
<span class='const'><span class='object_link'><a href="../BatchDelete.html" title="SidekiqUniqueJobs::BatchDelete (class)">BatchDelete</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="../BatchDelete.html#call-class_method" title="SidekiqUniqueJobs::BatchDelete.call (method)">call</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_orphans'>orphans</span><span class='comma'>,</span> <span class='id identifier rubyid_conn'>conn</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="considered_active?-instance_method">
#<strong>considered_active?</strong>(time_f) ⇒ <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
162
163
164</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 162</span>
<span class='kw'>def</span> <span class='id identifier rubyid_considered_active?'>considered_active?</span><span class='lparen'>(</span><span class='id identifier rubyid_time_f'>time_f</span><span class='rparen'>)</span>
<span class='lparen'>(</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='id identifier rubyid_reaper_timeout'>reaper_timeout</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span> <span class='op'><</span> <span class='id identifier rubyid_time_f'>time_f</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="enqueued?-instance_method">
#<strong>enqueued?</strong>(digest) ⇒ <tt>true</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the digest exists in a Sidekiq::Queue</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>digest</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>the current digest</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>)</span>
—
<div class='inline'><p>when digest exists in any queue</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
111
112
113
114
115
116
117
118
119
120
121</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 111</span>
<span class='kw'>def</span> <span class='id identifier rubyid_enqueued?'>enqueued?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='const'><span class='object_link'><a href="../../Sidekiq.html" title="Sidekiq (module)">Sidekiq</a></span></span><span class='period'>.</span><span class='id identifier rubyid_redis'>redis</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span>
<span class='id identifier rubyid_queues'>queues</span><span class='lparen'>(</span><span class='id identifier rubyid_conn'>conn</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_queue'>queue</span><span class='op'>|</span>
<span class='id identifier rubyid_entries'>entries</span><span class='lparen'>(</span><span class='id identifier rubyid_conn'>conn</span><span class='comma'>,</span> <span class='id identifier rubyid_queue'>queue</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span>
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>false</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="entries-instance_method">
#<strong>entries</strong>(conn, queue, &block) ⇒ <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>rubocop:disable Metrics/MethodLength</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 179</span>
<span class='kw'>def</span> <span class='id identifier rubyid_entries'>entries</span><span class='lparen'>(</span><span class='id identifier rubyid_conn'>conn</span><span class='comma'>,</span> <span class='id identifier rubyid_queue'>queue</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Metrics/MethodLength
</span> <span class='id identifier rubyid_queue_key'>queue_key</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>queue:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_queue'>queue</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
<span class='id identifier rubyid_initial_size'>initial_size</span> <span class='op'>=</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_llen'>llen</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_key'>queue_key</span><span class='rparen'>)</span>
<span class='id identifier rubyid_deleted_size'>deleted_size</span> <span class='op'>=</span> <span class='int'>0</span>
<span class='id identifier rubyid_page'>page</span> <span class='op'>=</span> <span class='int'>0</span>
<span class='id identifier rubyid_page_size'>page_size</span> <span class='op'>=</span> <span class='int'>50</span>
<span class='id identifier rubyid_loop'>loop</span> <span class='kw'>do</span>
<span class='id identifier rubyid_range_start'>range_start</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_page'>page</span> <span class='op'>*</span> <span class='id identifier rubyid_page_size'>page_size</span><span class='rparen'>)</span> <span class='op'>-</span> <span class='id identifier rubyid_deleted_size'>deleted_size</span>
<span class='id identifier rubyid_range_end'>range_end</span> <span class='op'>=</span> <span class='id identifier rubyid_range_start'>range_start</span> <span class='op'>+</span> <span class='id identifier rubyid_page_size'>page_size</span> <span class='op'>-</span> <span class='int'>1</span>
<span class='id identifier rubyid_entries'>entries</span> <span class='op'>=</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_lrange'>lrange</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_key'>queue_key</span><span class='comma'>,</span> <span class='id identifier rubyid_range_start'>range_start</span><span class='comma'>,</span> <span class='id identifier rubyid_range_end'>range_end</span><span class='rparen'>)</span>
<span class='id identifier rubyid_page'>page</span> <span class='op'>+=</span> <span class='int'>1</span>
<span class='kw'>break</span> <span class='kw'>if</span> <span class='id identifier rubyid_entries'>entries</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='id identifier rubyid_entries'>entries</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_deleted_size'>deleted_size</span> <span class='op'>=</span> <span class='id identifier rubyid_initial_size'>initial_size</span> <span class='op'>-</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_llen'>llen</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_key'>queue_key</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="in_sorted_set?-instance_method">
#<strong>in_sorted_set?</strong>(key, digest) ⇒ <tt>true</tt>, <tt>false</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks a sorted set for the existance of this digest</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>key</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>the key for the sorted set</p>
</div>
</li>
<li>
<span class='name'>digest</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>the digest to scan for</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>)</span>
—
<div class='inline'><p>when found</p>
</div>
</li>
<li>
<span class='type'>(<tt>false</tt>)</span>
—
<div class='inline'><p>when missing</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
210
211
212</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 210</span>
<span class='kw'>def</span> <span class='id identifier rubyid_in_sorted_set?'>in_sorted_set?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zscan_each'>zscan_each</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='label'>match:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>*</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_digest'>digest</span><span class='embexpr_end'>}</span><span class='tstring_content'>*</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>count:</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="match?-instance_method">
#<strong>match?</strong>(key_one, key_two) ⇒ <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
156
157
158
159
160</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 156</span>
<span class='kw'>def</span> <span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='id identifier rubyid_key_one'>key_one</span><span class='comma'>,</span> <span class='id identifier rubyid_key_two'>key_two</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_key_one'>key_one</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_key_two'>key_two</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='id identifier rubyid_key_one'>key_one</span><span class='period'>.</span><span class='id identifier rubyid_delete_suffix'>delete_suffix</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#RUN_SUFFIX-constant" title="SidekiqUniqueJobs::Orphans::RubyReaper::RUN_SUFFIX (constant)">RUN_SUFFIX</a></span></span><span class='rparen'>)</span> <span class='op'>==</span> <span class='id identifier rubyid_key_two'>key_two</span><span class='period'>.</span><span class='id identifier rubyid_delete_suffix'>delete_suffix</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="#RUN_SUFFIX-constant" title="SidekiqUniqueJobs::Orphans::RubyReaper::RUN_SUFFIX (constant)">RUN_SUFFIX</a></span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="orphans-instance_method">
#<strong>orphans</strong> ⇒ <tt><span class='object_link'><a href="../../Array.html" title="Array (class)">Array</a></span><String></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Find orphaned digests</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="../../Array.html" title="Array (class)">Array</a></span><String></tt>)</span>
—
<div class='inline'><p>an array of orphaned digests</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
57
58
59
60
61
62
63
64</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 57</span>
<span class='kw'>def</span> <span class='id identifier rubyid_orphans'>orphans</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_zrevrange'>zrevrange</span><span class='lparen'>(</span><span class='id identifier rubyid_digests'>digests</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_digest'>digest</span><span class='comma'>,</span> <span class='id identifier rubyid_memo'>memo</span><span class='op'>|</span>
<span class='kw'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_belongs_to_job?'>belongs_to_job?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='id identifier rubyid_memo'>memo</span> <span class='op'><<</span> <span class='id identifier rubyid_digest'>digest</span>
<span class='kw'>break</span> <span class='kw'>if</span> <span class='id identifier rubyid_memo'>memo</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>>=</span> <span class='id identifier rubyid_reaper_count'>reaper_count</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="queues-instance_method">
#<strong>queues</strong>(conn) { ... } ⇒ <tt>void</tt>
</h3><div class="docstring">
<div class="discussion">
<p class="note returns_void">This method returns an undefined value.</p><p>Loops through all the redis queues and yields them one by one</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>conn</span>
<span class='type'>(<tt><span class='object_link'><a href="../Redis.html" title="SidekiqUniqueJobs::Redis (module)">Redis</a></span></tt>)</span>
—
<div class='inline'><p>the connection to use for fetching queues</p>
</div>
</li>
</ul>
<p class="tag_title">Yields:</p>
<ul class="yield">
<li>
<span class='type'></span>
<div class='inline'><p>queues one at a time</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
175
176
177</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 175</span>
<span class='kw'>def</span> <span class='id identifier rubyid_queues'>queues</span><span class='lparen'>(</span><span class='id identifier rubyid_conn'>conn</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_sscan_each'>sscan_each</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>queues</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="retried?-instance_method">
#<strong>retried?</strong>(digest) ⇒ <tt>true</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the digest exists in the Sidekiq::RetrySet</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>digest</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>the current digest</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>)</span>
—
<div class='inline'><p>when digest exists in retry set</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
100
101
102</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 100</span>
<span class='kw'>def</span> <span class='id identifier rubyid_retried?'>retried?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='id identifier rubyid_in_sorted_set?'>in_sorted_set?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#RETRY-constant" title="SidekiqUniqueJobs::RETRY (constant)">RETRY</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="scheduled?-instance_method">
#<strong>scheduled?</strong>(digest) ⇒ <tt>true</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the digest exists in the Sidekiq::ScheduledSet</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>digest</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>the current digest</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>)</span>
—
<div class='inline'><p>when digest exists in scheduled set</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
89
90
91</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb', line 89</span>
<span class='kw'>def</span> <span class='id identifier rubyid_scheduled?'>scheduled?</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='id identifier rubyid_in_sorted_set?'>in_sorted_set?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#SCHEDULE-constant" title="SidekiqUniqueJobs::SCHEDULE (constant)">SCHEDULE</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_digest'>digest</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Sep 27 15:29:09 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.2).
</div>
</div>
</body>
</html>