# AllowListPolicy

<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>AllowListPolicy<span class="signature">(childPolicy, allowList)</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>A load balancing policy wrapper that ensure that only hosts from a provided
allow list will ever be returned.</p>
<p>This policy wraps another load balancing policy and will delegate the choice
of hosts to the wrapped policy with the exception that only hosts contained
in the allow list provided when constructing this policy will ever be
returned. Any host not in the while list will be considered ignored
and thus will not be connected to.</p>
<p>This policy can be useful to ensure that the driver only connects to a
predefined set of hosts. Keep in mind however that this policy defeats
somewhat the host auto-detection of the driver. As such, this policy is only
useful in a few special cases or for testing, but is not optimal in general.
If all you want to do is limiting connections to hosts of the local
data-center then you should use DCAwareRoundRobinPolicy and <em>not</em> this policy
in particular.</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="AllowListPolicy"><span class="type-signature"></span>new AllowListPolicy<span class="signature">(childPolicy, allowList)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Create a new policy that wraps the provided child policy but only &quot;allow&quot; hosts
from the provided list.</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>childPolicy</code></td>
            

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


            
            </td>

            

            

            <td class="description last"><p>the wrapped policy.
If the child policy filters some of the hosts out, only hosts present
in allow list and accepted by child policy will be contacted by the driver.</p></td>
        </tr>

    

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

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


            
            </td>

            

            

            <td class="description last"><p>The hosts address in the format ipAddress:port.
Only hosts from this list may get connected
to (whether they will get connected to or not depends on the child policy).</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#L216" target="_blank" rel="noopener">policies/load-balancing.js, line 216</a></p></div>




















    
    

    
        </div>

## Extends

<div class="jsdoc-content">

        


    <ul>
        <li>LoadBalancingPolicy</li>
    </ul>


    

    

    

    

    

    

    

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