# LoadBalancingPolicy

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>
            <span class="ancestors"><a href="index.html">policies/loadBalancing</a>~</span>LoadBalancingPolicy<span class="signature">()</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>Base class for Load Balancing Policies</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="LoadBalancingPolicy"><span class="type-signature"></span>new LoadBalancingPolicy<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/load-balancing.js#L16" target="_blank" rel="noopener">policies/load-balancing.js, line 16</a></p></div>




















    
    

    

    

    

    

    

    

    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

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

    



<div class="description">
    <p>Returns the distance assigned by this policy to the provided host.</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>host</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="Host.html">Host</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/load-balancing.js#L33" target="_blank" rel="noopener">policies/load-balancing.js, line 33</a></p></div>




















        
            

    

    
    <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/load-balancing.js#L55" target="_blank" rel="noopener">policies/load-balancing.js, line 55</a></p></div>




















        
            

    

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

    



<div class="description">
    <p>Initializes the load balancing policy, called after the driver obtained the information of the cluster.</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>

    

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

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


            
            </td>

            

            

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

    

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

            <td class="type">
            
                
<span class="param-type">function</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/load-balancing.js#L24" target="_blank" rel="noopener">policies/load-balancing.js, line 24</a></p></div>




















        
            

    

    
    <h4 class="name" id="newQueryPlan"><span class="type-signature"></span>newQueryPlan<span class="signature">(keyspace, executionOptions, callback)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns an iterator with the hosts for a new query.
Each new query will call this method. The first host in the result will
then be used to perform the query.</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>Name of currently logged keyspace at <code>Client</code> level.</p></td>
        </tr>

    

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

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

<span class="param-type">null</span>


            
            </td>

            

            

            <td class="description last"><p>The information related to the execution of the request.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>The function to be invoked with the error as first parameter and the host iterator as
second parameter.</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/load-balancing.js#L45" target="_blank" rel="noopener">policies/load-balancing.js, line 45</a></p></div></div>
