# SpeculativeExecutionPolicy

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature">(abstract) </span></span>
            <span class="ancestors"><a href="index.html">policies/speculativeExecution</a>~</span>SpeculativeExecutionPolicy<span class="signature">()</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>The policy that decides if the driver will send speculative queries to the next hosts when the current host takes too
long to respond.</p>
<p>Note that only idempotent statements will be speculatively retried.</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="SpeculativeExecutionPolicy"><span class="type-signature">(abstract) </span>new SpeculativeExecutionPolicy<span class="signature">()</span><span class="type-signature"></span></h4>
    

    















<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/speculative-execution.js#L15" target="_blank" rel="noopener">policies/speculative-execution.js, line 15</a></p></div>




















    
    

    

    

    

    

    

    

    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

    
    <h4 class="name" id="getOptions"><span class="type-signature"></span>getOptions<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Gets an associative array containing the policy options.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/speculative-execution.js#L45" target="_blank" rel="noopener">policies/speculative-execution.js, line 45</a></p></div>




















        
            

    

    
    <h4 class="name" id="init"><span class="type-signature">(abstract) </span>init<span class="signature">(client)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Initialization method that gets invoked on Client startup.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>client</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="../../Client.html">Client</a></span>


            
            </td>

            

            

            <td class="description last"></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/speculative-execution.js#L22" target="_blank" rel="noopener">policies/speculative-execution.js, line 22</a></p></div>




















        
            

    

    
    <h4 class="name" id="newPlan"><span class="type-signature">(abstract) </span>newPlan<span class="signature">(keyspace, queryInfo)</span><span class="type-signature"> &rarr; {Object}</span></h4>
    

    



<div class="description">
    <p>Gets the plan to use for a new query.
Returns an object with a <code>nextExecution()</code> method, which returns a positive number representing the
amount of milliseconds to delay the next execution or a non-negative number to avoid further executions.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>keyspace</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>The currently logged keyspace.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>queryInfo</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>
|

<span class="param-type">Array&lt;String></span>


            
            </td>

            

            

            <td class="description last"><p>The query, or queries in the case of batches, for which to build a plan.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/speculative-execution.js#L37" target="_blank" rel="noopener">policies/speculative-execution.js, line 37</a></p></div>















<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="shutdown"><span class="type-signature">(abstract) </span>shutdown<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Gets invoked at client shutdown, giving the opportunity to the implementor to perform cleanup.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/policies/speculative-execution.js#L27" target="_blank" rel="noopener">policies/speculative-execution.js, line 27</a></p></div></div>
