# 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.7.1/lib/policies/load-balancing.ts#L46" target="_blank" rel="noopener">policies/load-balancing.ts, line 46</a></p></div>




















    
    

    

    

    

    

    

    

    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

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

    



<div class="description">
    <p>Returns the distance assigned by this policy to the provided host.</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/load-balancing.ts#L63" target="_blank" rel="noopener">policies/load-balancing.ts, line 63</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.7.1/lib/policies/load-balancing.ts#L89" target="_blank" rel="noopener">policies/load-balancing.ts, line 89</a></p></div>




















        
            

    

    
    <h4 class="name" id="init"><span class="type-signature"></span>init<span class="signature">()</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>













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