# SpeculativeExecutionPolicy

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature">(abstract) </span></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.7.1/lib/policies/speculative-execution.ts#L22" target="_blank" rel="noopener">policies/speculative-execution.ts, line 22</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.7.1/lib/policies/speculative-execution.ts#L53" target="_blank" rel="noopener">policies/speculative-execution.ts, line 53</a></p></div>




















        
            

    

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

    



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













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.7.1/lib/policies/speculative-execution.ts#L28" target="_blank" rel="noopener">policies/speculative-execution.ts, line 28</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"></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">
            
            </td>

            

            

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

    

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

            <td class="type">
            
            </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.7.1/lib/policies/speculative-execution.ts#L42" target="_blank" rel="noopener">policies/speculative-execution.ts, line 42</a></p></div>




















        
            

    

    
    <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.7.1/lib/policies/speculative-execution.ts#L33" target="_blank" rel="noopener">policies/speculative-execution.ts, line 33</a></p></div></div>
