mhenrixon/sidekiq-unique-jobs

View on GitHub
doc/SidekiqUniqueJobs/Lock/Validator.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>
  Class: SidekiqUniqueJobs::Lock::Validator
  
    &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::Lock::Validator";
  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 (V)</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="../Lock.html" title="SidekiqUniqueJobs::Lock (class)">Lock</a></span></span>
     &raquo; 
    <span class="title">Validator</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::Lock::Validator
  
  
  
</h1>
<div class="box_info">
  
  <dl>
    <dt>Inherits:</dt>
    <dd>
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">SidekiqUniqueJobs::Lock::Validator</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
    </dd>
  </dl>
  

  
  
  
  
  

  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/sidekiq_unique_jobs/lock/validator.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>Validator base class to avoid some duplication</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="DEPRECATED_KEYS-constant" class="">DEPRECATED_KEYS =
          <div class="docstring">
  <div class="discussion">
    <p>Returns a hash mapping of deprecated keys and their new value.</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>a hash mapping of deprecated keys and their new value</p>
</div>
      
    </li>
  
</ul>

</div>
        </dt>
        <dd><pre class="code"><span class='lbrace'>{</span>
  <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#UNIQUE-constant" title="SidekiqUniqueJobs::UNIQUE (constant)">UNIQUE</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>=&gt;</span> <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#LOCK-constant" title="SidekiqUniqueJobs::LOCK (constant)">LOCK</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span>
  <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#UNIQUE_ARGS-constant" title="SidekiqUniqueJobs::UNIQUE_ARGS (constant)">UNIQUE_ARGS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>=&gt;</span> <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#LOCK_ARGS_METHOD-constant" title="SidekiqUniqueJobs::LOCK_ARGS_METHOD (constant)">LOCK_ARGS_METHOD</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span>
  <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#LOCK_ARGS-constant" title="SidekiqUniqueJobs::LOCK_ARGS (constant)">LOCK_ARGS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>=&gt;</span> <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#LOCK_ARGS_METHOD-constant" title="SidekiqUniqueJobs::LOCK_ARGS_METHOD (constant)">LOCK_ARGS_METHOD</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span>
  <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#UNIQUE_PREFIX-constant" title="SidekiqUniqueJobs::UNIQUE_PREFIX (constant)">UNIQUE_PREFIX</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>=&gt;</span> <span class='const'><span class='object_link'><a href="../../SidekiqUniqueJobs.html#LOCK_PREFIX-constant" title="SidekiqUniqueJobs::LOCK_PREFIX (constant)">LOCK_PREFIX</a></span></span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span>
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</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="#lock_config-instance_method" title="#lock_config (instance method)">#<strong>lock_config</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
    
      <span class="note title readonly">readonly</span>
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Returns the value of attribute lock_config.</p>
</div></span>
  
</li>

    
  </ul>




  
    <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="#validate-class_method" title="validate (class method)">.<strong>validate</strong>(options)  &#x21d2; LockConfig </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Shorthand for <code>new(options).validate</code>.</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="#handle_deprecations-instance_method" title="#handle_deprecations (instance method)">#<strong>handle_deprecations</strong>  &#x21d2; void </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Validate deprecated keys   adds useful information about how to proceed with fixing handle_deprecations.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(options)  &#x21d2; Validator </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Initialize a new validator.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#validate-instance_method" title="#validate (instance method)">#<strong>validate</strong>  &#x21d2; LockConfig </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Validate the workers lock configuration.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#validate_client-instance_method" title="#validate_client (instance method)">#<strong>validate_client</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Validates the client configuration.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#validate_server-instance_method" title="#validate_server (instance method)">#<strong>validate_server</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Validates the server configuration.</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>(options)  &#x21d2; <tt><span class='object_link'><a href="" title="SidekiqUniqueJobs::Lock::Validator (class)">Validator</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Initialize a new validator</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>options</span>
      
      
        <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>the sidekiq_options for the worker being validated</p>
</div>
      
    </li>
  
</ul>


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


41
42
43
44
45</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/lock/validator.rb', line 41</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
  <span class='ivar'>@options</span>     <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_transform_keys'>transform_keys</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span>
  <span class='ivar'>@lock_config</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../LockConfig.html" title="SidekiqUniqueJobs::LockConfig (class)">LockConfig</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../LockConfig.html#initialize-instance_method" title="SidekiqUniqueJobs::LockConfig#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_handle_deprecations'>handle_deprecations</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="lock_config-instance_method">
  
    #<strong>lock_config</strong>  &#x21d2; <tt>Object</tt>  <span class="extras">(readonly)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Returns the value of attribute lock_config.</p>


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

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


34
35
36</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/lock/validator.rb', line 34</span>

<span class='kw'>def</span> <span class='id identifier rubyid_lock_config'>lock_config</span>
  <span class='ivar'>@lock_config</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


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

    
      <div class="method_details first">
  <h3 class="signature first" id="validate-class_method">
  
    .<strong>validate</strong>(options)  &#x21d2; <tt><span class='object_link'><a href="../LockConfig.html" title="SidekiqUniqueJobs::LockConfig (class)">LockConfig</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Shorthand for <code>new(options).validate</code></p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>options</span>
      
      
        <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>the sidekiq_options for the worker being validated</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../LockConfig.html" title="SidekiqUniqueJobs::LockConfig (class)">LockConfig</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>the lock configuration with errors if any</p>
</div>
      
    </li>
  
</ul>

</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/lock/validator.rb', line 27</span>

<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</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="handle_deprecations-instance_method">
  
    #<strong>handle_deprecations</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>Validate deprecated keys
  adds useful information about how to proceed with fixing handle_deprecations</p>


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

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


73
74
75
76
77
78
79</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/lock/validator.rb', line 73</span>

<span class='kw'>def</span> <span class='id identifier rubyid_handle_deprecations'>handle_deprecations</span>
  <span class='const'><span class='object_link'><a href="#DEPRECATED_KEYS-constant" title="SidekiqUniqueJobs::Lock::Validator::DEPRECATED_KEYS (constant)">DEPRECATED_KEYS</a></span></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_old'>old</span><span class='comma'>,</span> <span class='id identifier rubyid_new'>new</span><span class='op'>|</span>
    <span class='kw'>next</span> <span class='kw'>unless</span> <span class='ivar'>@options</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_old'>old</span><span class='rparen'>)</span>

    <span class='id identifier rubyid_lock_config'>lock_config</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='lbracket'>[</span><span class='id identifier rubyid_old'>old</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>is deprecated, use `</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_new'>new</span><span class='embexpr_end'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='ivar'>@options</span><span class='lbracket'>[</span><span class='id identifier rubyid_old'>old</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>` instead.</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="validate-instance_method">
  
    #<strong>validate</strong>  &#x21d2; <tt><span class='object_link'><a href="../LockConfig.html" title="SidekiqUniqueJobs::LockConfig (class)">LockConfig</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Validate the workers lock configuration</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="../LockConfig.html" title="SidekiqUniqueJobs::LockConfig (class)">LockConfig</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>the lock configuration with errors if any</p>
</div>
      
    </li>
  
</ul>

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


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

<span class='kw'>def</span> <span class='id identifier rubyid_validate'>validate</span>
  <span class='kw'>case</span> <span class='id identifier rubyid_lock_config'>lock_config</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span>
  <span class='kw'>when</span> <span class='symbol'>:while_executing</span>
    <span class='id identifier rubyid_validate_server'>validate_server</span>
  <span class='kw'>when</span> <span class='symbol'>:until_executing</span>
    <span class='id identifier rubyid_validate_client'>validate_client</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_validate_client'>validate_client</span>
    <span class='id identifier rubyid_validate_server'>validate_server</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_lock_config'>lock_config</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="validate_client-instance_method">
  
    #<strong>validate_client</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Validates the client configuration</p>


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

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


84
85
86</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/lock/validator.rb', line 84</span>

<span class='kw'>def</span> <span class='id identifier rubyid_validate_client'>validate_client</span>
  <span class='const'><span class='object_link'><a href="ClientValidator.html" title="SidekiqUniqueJobs::Lock::ClientValidator (class)">ClientValidator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_validate'><span class='object_link'><a href="ClientValidator.html#validate-class_method" title="SidekiqUniqueJobs::Lock::ClientValidator.validate (method)">validate</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_lock_config'>lock_config</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="validate_server-instance_method">
  
    #<strong>validate_server</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Validates the server configuration</p>


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

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


91
92
93</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/lock/validator.rb', line 91</span>

<span class='kw'>def</span> <span class='id identifier rubyid_validate_server'>validate_server</span>
  <span class='const'><span class='object_link'><a href="ServerValidator.html" title="SidekiqUniqueJobs::Lock::ServerValidator (class)">ServerValidator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_validate'><span class='object_link'><a href="ServerValidator.html#validate-class_method" title="SidekiqUniqueJobs::Lock::ServerValidator.validate (method)">validate</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_lock_config'>lock_config</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:08 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>