mhenrixon/sidekiq-unique-jobs

View on GitHub
doc/SidekiqUniqueJobs/Orphans/Manager.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: SidekiqUniqueJobs::Orphans::Manager
  
    &mdash; 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::Manager";
  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 (M)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Orphans.html" title="SidekiqUniqueJobs::Orphans (module)">Orphans</a></span></span>
     &raquo; 
    <span class="title">Manager</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>Module: SidekiqUniqueJobs::Orphans::Manager
  
  
  
</h1>
<div class="box_info">
  

  
  
  
  
  

  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/sidekiq_unique_jobs/orphans/manager.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>Manages the orphan reaper</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="DRIFT_FACTOR-constant" class="">DRIFT_FACTOR =
          <div class="docstring">
  <div class="discussion">
    <p>Returns the amount to add to the reaper interval.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>the amount to add to the reaper interval</p>
</div>
      
    </li>
  
</ul>

</div>
        </dt>
        <dd><pre class="code"><span class='float'>0.02</span></pre></dd>
      
        <dt id="REAPERS-constant" class="">REAPERS =
          <div class="docstring">
  <div class="discussion">
    <p>Returns allowed reapers (:ruby or :lua).</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>allowed reapers (:ruby or :lua)</p>
</div>
      
    </li>
  
</ul>

</div>
        </dt>
        <dd><pre class="code"><span class='lbracket'>[</span><span class='symbol'>:ruby</span><span class='comma'>,</span> <span class='symbol'>:lua</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
      
    </dl>
  







  
    <h2>
      Class Method Summary
      <small><a href="#" class="summary_toggle">collapse</a></small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#current_timestamp-class_method" title="current_timestamp (class method)">.<strong>current_timestamp</strong>  &#x21d2; Integer </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Current time (as integer value).</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#default_task-class_method" title="default_task (class method)">.<strong>default_task</strong>  &#x21d2; SidekiqUniqueJobs::TimerTask </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>A properly configured timer task.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#disabled%3F-class_method" title="disabled? (class method)">.<strong>disabled?</strong>  &#x21d2; true, false </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Checks if reaping is disabled.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#drift_reaper_interval-class_method" title="drift_reaper_interval (class method)">.<strong>drift_reaper_interval</strong>  &#x21d2; Integer </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Reaper interval with a little drift   Redis isn&#39;t exact enough so to give a little bufffer,   we add a tiny value to the reaper interval.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#enabled%3F-class_method" title="enabled? (class method)">.<strong>enabled?</strong>  &#x21d2; true, false </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Checks if reaping is enabled.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#logging_context-class_method" title="logging_context (class method)">.<strong>logging_context</strong>  &#x21d2; Hash, String </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>A context to use for all log entries.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#reaper-class_method" title="reaper (class method)">.<strong>reaper</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#reaper_interval-class_method" title="reaper_interval (class method)">.<strong>reaper_interval</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#reaper_timeout-class_method" title="reaper_timeout (class method)">.<strong>reaper_timeout</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#refresh_reaper_mutex-class_method" title="refresh_reaper_mutex (class method)">.<strong>refresh_reaper_mutex</strong>  &#x21d2; void </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Updates mutex key.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#register_reaper_process-class_method" title="register_reaper_process (class method)">.<strong>register_reaper_process</strong>  &#x21d2; void </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Writes a mutex key to redis.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#registered%3F-class_method" title="registered? (class method)">.<strong>registered?</strong>  &#x21d2; true, false </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Checks if a reaper is registered.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#start-class_method" title="start (class method)">.<strong>start</strong>(test_task = nil)  &#x21d2; SidekiqUniqueJobs::TimerTask </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Starts a separate thread that periodically reaps orphans.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#stop-class_method" title="stop (class method)">.<strong>stop</strong>  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Stops the thread that reaps orphans.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#task-class_method" title="task (class method)">.<strong>task</strong>  &#x21d2; &lt;type&gt; </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The task that runs the reaper.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#task=-class_method" title="task= (class method)">.<strong>task=</strong>(task)  &#x21d2; void </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Store a task to use for scheduled execution.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#timer_task_options-class_method" title="timer_task_options (class method)">.<strong>timer_task_options</strong>  &#x21d2; Hash </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Arguments passed on to the timer task.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#unregister_reaper_process-class_method" title="unregister_reaper_process (class method)">.<strong>unregister_reaper_process</strong>  &#x21d2; void </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Removes mutex key from redis.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#unregistered%3F-class_method" title="unregistered? (class method)">.<strong>unregistered?</strong>  &#x21d2; true, false </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Checks if that reapers are not registerd.</p>
</div></span>
  
</li>

      
    </ul>
  



  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="current_timestamp-class_method">
  
    .<strong>current_timestamp</strong>  &#x21d2; <tt>Integer</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Current time (as integer value)</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


243
244
245</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 243</span>

<span class='kw'>def</span> <span class='id identifier rubyid_current_timestamp'>current_timestamp</span>
  <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="default_task-class_method">
  
    .<strong>default_task</strong>  &#x21d2; <tt><span class='object_link'><a href="../TimerTask.html" title="SidekiqUniqueJobs::TimerTask (class)">SidekiqUniqueJobs::TimerTask</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>A properly configured timer task</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="../TimerTask.html" title="SidekiqUniqueJobs::TimerTask (class)">SidekiqUniqueJobs::TimerTask</a></span></tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


82
83
84
85
86
87
88
89
90
91</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 82</span>

<span class='kw'>def</span> <span class='id identifier rubyid_default_task'>default_task</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="../TimerTask.html" title="SidekiqUniqueJobs::TimerTask (class)">TimerTask</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_timer_task_options'>timer_task_options</span><span class='rparen'>)</span> <span class='kw'>do</span>
    <span class='id identifier rubyid_with_logging_context'>with_logging_context</span> <span class='kw'>do</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_refresh_reaper_mutex'>refresh_reaper_mutex</span>
        <span class='const'><span class='object_link'><a href="../Orphans.html" title="SidekiqUniqueJobs::Orphans (module)">Orphans</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Reaper.html" title="SidekiqUniqueJobs::Orphans::Reaper (class)">Reaper</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="Reaper.html#call-class_method" title="SidekiqUniqueJobs::Orphans::Reaper.call (method)">call</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_conn'>conn</span><span class='rparen'>)</span>
      <span class='kw'>end</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="disabled?-class_method">
  
    .<strong>disabled?</strong>  &#x21d2; <tt>true</tt>, <tt>false</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Checks if reaping is disabled</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
      
      
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="#enabled%3F-class_method" title="SidekiqUniqueJobs::Orphans::Manager.enabled? (method)">enabled?</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


182
183
184</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 182</span>

<span class='kw'>def</span> <span class='id identifier rubyid_disabled?'>disabled?</span>
  <span class='op'>!</span><span class='id identifier rubyid_enabled?'>enabled?</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="drift_reaper_interval-class_method">
  
    .<strong>drift_reaper_interval</strong>  &#x21d2; <tt>Integer</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Reaper interval with a little drift
  Redis isn&#39;t exact enough so to give a little bufffer,
  we add a tiny value to the reaper interval.</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Integer</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><description></p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


233
234
235</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 233</span>

<span class='kw'>def</span> <span class='id identifier rubyid_drift_reaper_interval'>drift_reaper_interval</span>
  <span class='id identifier rubyid_reaper_interval'>reaper_interval</span> <span class='op'>+</span> <span class='lparen'>(</span><span class='id identifier rubyid_reaper_interval'>reaper_interval</span> <span class='op'>*</span> <span class='const'><span class='object_link'><a href="#DRIFT_FACTOR-constant" title="SidekiqUniqueJobs::Orphans::Manager::DRIFT_FACTOR (constant)">DRIFT_FACTOR</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="enabled?-class_method">
  
    .<strong>enabled?</strong>  &#x21d2; <tt>true</tt>, <tt>false</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Checks if reaping is enabled</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


191
192
193</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 191</span>

<span class='kw'>def</span> <span class='id identifier rubyid_enabled?'>enabled?</span>
  <span class='const'><span class='object_link'><a href="#REAPERS-constant" title="SidekiqUniqueJobs::Orphans::Manager::REAPERS (constant)">REAPERS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_reaper'>reaper</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="logging_context-class_method">
  
    .<strong>logging_context</strong>  &#x21d2; <tt><span class='object_link'><a href="../../Hash.html" title="Hash (class)">Hash</a></span></tt>, <tt>String</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>A context to use for all log entries</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="../../Hash.html" title="Hash (class)">Hash</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>when logger responds to <code>:with_context</code></p>
</div>
      
    </li>
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>when logger does not responds to <code>:with_context</code></p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


144
145
146
147
148
149
150</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 144</span>

<span class='kw'>def</span> <span class='id identifier rubyid_logging_context'>logging_context</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_logger_context_hash?'>logger_context_hash?</span>
    <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uniquejobs</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>reaper</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
  <span class='kw'>else</span>
    <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>uniquejobs=orphan-reaper</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="reaper-class_method">
  
    .<strong>reaper</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li>Config#reaper</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


119
120
121</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 119</span>

<span class='kw'>def</span> <span class='id identifier rubyid_reaper'>reaper</span>
  <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span><span class='period'>.</span><span class='id identifier rubyid_config'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#config-class_method" title="SidekiqUniqueJobs.config (method)">config</a></span></span><span class='period'>.</span><span class='id identifier rubyid_reaper'>reaper</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="reaper_interval-class_method">
  
    .<strong>reaper_interval</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li>Config#reaper_interval</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


126
127
128</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 126</span>

<span class='kw'>def</span> <span class='id identifier rubyid_reaper_interval'>reaper_interval</span>
  <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span><span class='period'>.</span><span class='id identifier rubyid_config'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#config-class_method" title="SidekiqUniqueJobs.config (method)">config</a></span></span><span class='period'>.</span><span class='id identifier rubyid_reaper_interval'>reaper_interval</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="reaper_timeout-class_method">
  
    .<strong>reaper_timeout</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li>Config#reaper_timeout</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


133
134
135</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 133</span>

<span class='kw'>def</span> <span class='id identifier rubyid_reaper_timeout'>reaper_timeout</span>
  <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span><span class='period'>.</span><span class='id identifier rubyid_config'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#config-class_method" title="SidekiqUniqueJobs.config (method)">config</a></span></span><span class='period'>.</span><span class='id identifier rubyid_reaper_timeout'>reaper_timeout</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="refresh_reaper_mutex-class_method">
  
    .<strong>refresh_reaper_mutex</strong>  &#x21d2; <tt>void</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p class="note returns_void">This method returns an undefined value.</p><p>Updates mutex key</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


211
212
213</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 211</span>

<span class='kw'>def</span> <span class='id identifier rubyid_refresh_reaper_mutex'>refresh_reaper_mutex</span>
  <span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#UNIQUE_REAPER-constant" title="SidekiqUniqueJobs::UNIQUE_REAPER (constant)">UNIQUE_REAPER</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_current_timestamp'>current_timestamp</span><span class='comma'>,</span> <span class='label'>ex:</span> <span class='id identifier rubyid_drift_reaper_interval'>drift_reaper_interval</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="register_reaper_process-class_method">
  
    .<strong>register_reaper_process</strong>  &#x21d2; <tt>void</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p class="note returns_void">This method returns an undefined value.</p><p>Writes a mutex key to redis</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


201
202
203</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 201</span>

<span class='kw'>def</span> <span class='id identifier rubyid_register_reaper_process'>register_reaper_process</span>
  <span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#UNIQUE_REAPER-constant" title="SidekiqUniqueJobs::UNIQUE_REAPER (constant)">UNIQUE_REAPER</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_current_timestamp'>current_timestamp</span><span class='comma'>,</span> <span class='label'>nx:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>ex:</span> <span class='id identifier rubyid_drift_reaper_interval'>drift_reaper_interval</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="registered?-class_method">
  
    .<strong>registered?</strong>  &#x21d2; <tt>true</tt>, <tt>false</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Checks if a reaper is registered</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


158
159
160
161
162</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 158</span>

<span class='kw'>def</span> <span class='id identifier rubyid_registered?'>registered?</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_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#UNIQUE_REAPER-constant" title="SidekiqUniqueJobs::UNIQUE_REAPER (constant)">UNIQUE_REAPER</a></span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>+</span> <span class='id identifier rubyid_drift_reaper_interval'>drift_reaper_interval</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_current_timestamp'>current_timestamp</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="start-class_method">
  
    .<strong>start</strong>(test_task = nil)  &#x21d2; <tt><span class='object_link'><a href="../TimerTask.html" title="SidekiqUniqueJobs::TimerTask (class)">SidekiqUniqueJobs::TimerTask</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Starts a separate thread that periodically reaps orphans</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="../TimerTask.html" title="SidekiqUniqueJobs::TimerTask (class)">SidekiqUniqueJobs::TimerTask</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>the task that was started</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 33</span>

<span class='kw'>def</span> <span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='id identifier rubyid_test_task'>test_task</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable
</span>  <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_disabled?'>disabled?</span>
  <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_registered?'>registered?</span>

  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_task'>task</span> <span class='op'>=</span> <span class='id identifier rubyid_test_task'>test_task</span> <span class='op'>||</span> <span class='id identifier rubyid_default_task'>default_task</span>

  <span class='id identifier rubyid_with_logging_context'>with_logging_context</span> <span class='kw'>do</span>
    <span class='id identifier rubyid_register_reaper_process'>register_reaper_process</span>
    <span class='id identifier rubyid_log_info'>log_info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Starting Reaper</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>

    <span class='id identifier rubyid_task'>task</span><span class='period'>.</span><span class='id identifier rubyid_add_observer'>add_observer</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Observer.html" title="SidekiqUniqueJobs::Orphans::Observer (class)">Observer</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_task'>task</span><span class='period'>.</span><span class='id identifier rubyid_execute'>execute</span>
    <span class='id identifier rubyid_task'>task</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="stop-class_method">
  
    .<strong>stop</strong>  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Stops the thread that reaps orphans</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">


55
56
57
58
59
60
61
62
63
64</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 55</span>

<span class='kw'>def</span> <span class='id identifier rubyid_stop'>stop</span>
  <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_disabled?'>disabled?</span>
  <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_unregistered?'>unregistered?</span>

  <span class='id identifier rubyid_with_logging_context'>with_logging_context</span> <span class='kw'>do</span>
    <span class='id identifier rubyid_log_info'>log_info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Stopping Reaper</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id identifier rubyid_unregister_reaper_process'>unregister_reaper_process</span>
    <span class='id identifier rubyid_task'>task</span><span class='period'>.</span><span class='id identifier rubyid_shutdown'>shutdown</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="task-class_method">
  
    .<strong>task</strong>  &#x21d2; <tt>&lt;type&gt;</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>The task that runs the reaper</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>&lt;type&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><description></p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


72
73
74</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 72</span>

<span class='kw'>def</span> <span class='id identifier rubyid_task'>task</span>
  <span class='ivar'>@task</span> <span class='op'>||=</span> <span class='id identifier rubyid_default_task'>default_task</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="task=-class_method">
  
    .<strong>task=</strong>(task)  &#x21d2; <tt>void</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p class="note returns_void">This method returns an undefined value.</p><p>Store a task to use for scheduled execution</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>task</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../TimerTask.html" title="SidekiqUniqueJobs::TimerTask (class)">SidekiqUniqueJobs::TimerTask</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>the task to use</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/manager.rb', line 100</span>

<span class='kw'>def</span> <span class='id identifier rubyid_task='>task=</span><span class='lparen'>(</span><span class='id identifier rubyid_task'>task</span><span class='rparen'>)</span>
  <span class='ivar'>@task</span> <span class='op'>=</span> <span class='id identifier rubyid_task'>task</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="timer_task_options-class_method">
  
    .<strong>timer_task_options</strong>  &#x21d2; <tt><span class='object_link'><a href="../../Hash.html" title="Hash (class)">Hash</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Arguments passed on to the timer task</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="../../Hash.html" title="Hash (class)">Hash</a></span></tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


110
111
112
113
114</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 110</span>

<span class='kw'>def</span> <span class='id identifier rubyid_timer_task_options'>timer_task_options</span>
  <span class='lbrace'>{</span> <span class='label'>run_now:</span> <span class='kw'>true</span><span class='comma'>,</span>
    <span class='label'>execution_interval:</span> <span class='id identifier rubyid_reaper_interval'>reaper_interval</span><span class='comma'>,</span>
    <span class='label'>timeout_interval:</span> <span class='id identifier rubyid_reaper_timeout'>reaper_timeout</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="unregister_reaper_process-class_method">
  
    .<strong>unregister_reaper_process</strong>  &#x21d2; <tt>void</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p class="note returns_void">This method returns an undefined value.</p><p>Removes mutex key from redis</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


221
222
223</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 221</span>

<span class='kw'>def</span> <span class='id identifier rubyid_unregister_reaper_process'>unregister_reaper_process</span>
  <span class='id identifier rubyid_redis'>redis</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_conn'>conn</span><span class='op'>|</span> <span class='id identifier rubyid_conn'>conn</span><span class='period'>.</span><span class='id identifier rubyid_del'>del</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#UNIQUE_REAPER-constant" title="SidekiqUniqueJobs::UNIQUE_REAPER (constant)">UNIQUE_REAPER</a></span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="unregistered?-class_method">
  
    .<strong>unregistered?</strong>  &#x21d2; <tt>true</tt>, <tt>false</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Checks if that reapers are not registerd</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
      
      
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="#registered%3F-class_method" title="SidekiqUniqueJobs::Orphans::Manager.registered? (method)">registered?</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


171
172
173</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/orphans/manager.rb', line 171</span>

<span class='kw'>def</span> <span class='id identifier rubyid_unregistered?'>unregistered?</span>
  <span class='op'>!</span><span class='id identifier rubyid_registered?'>registered?</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Mon Sep 27 15:29:06 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>