<p>Apparently, in its current implementation load_balancer module could be used in the only one way:</p>

<p>load balance on static destinations group and static resources list.<br>
first - because do_load_balance() ignores new group.<br>
second - because do_load_balance() - clean up dialog profiles according to new resources string. not a previous one.</p>

<p>I tried to enhance this module to be able to use it in the following ways (this is just a sample to cover all possible cases):</p>

<p>route[LB1] {<br>
      if( load_balancer("", "res1;res2") ) {<br>
           t_on_failure("LB2_RETRY");<br>
           route(RELAY);<br>
       }<br>
       route(LB2);<br>
}<br>
route[LB2] {<br>
      if( load_balancer("", "res3") ) {<br>
           t_on_failure("LB2_RETRY");<br>
           route(RELAY);<br>
       }<br>
       route(LB3);<br>
}<br>
failure_route[LB2_RETRY] {<br>
       route(LB2);<br>
}<br>
route[LB3] {<br>
      if( load_balancer("", "res4") ) {<br>
           t_on_failure("LB3_RETRY");<br>
           route(RELAY);<br>
       }<br>
       route(FAILURE);<br>
}<br>
failure_route[LB3_RETRY] {<br>
        route(LB3);<br>
}</p>

<p>I also need to implement a scenario where I load-balance some amount of calls and reject excessive load, but some high-priority calls have to be handled at all cost. so I still want to load-balance them to select less busiest node, but ignore the fact that the amount of traffic on this node might exceed configured limits.</p>

<p>Also, if i register call as a 'load' using lb_count_call() function, I want to be able undo it.</p>

<hr>

<h4>You can merge this Pull Request by running</h4>
<pre>  git pull https://github.com/shripchenko/opensips master</pre>
<p>Or view, comment on, or merge it at:</p>
<p>&nbsp;&nbsp;<a href='https://github.com/OpenSIPS/opensips/pull/345'>https://github.com/OpenSIPS/opensips/pull/345</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>changed load_ballance() function to</li>
  <li>add lb_reset() function to reset LB state in case you want to stop load-ballancing call</li>
  <li>changed lb_count_call(ip,port,grp,resources[,mode]) function to allow one parameter</li>
  <li>introduced two more algorithms for load_balance() that the same as existing, but</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/345/files#diff-0">modules/load_balancer/lb_data.c</a>
    (528)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/345/files#diff-1">modules/load_balancer/lb_data.h</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/345/files#diff-2">modules/load_balancer/load_balancer.c</a>
    (40)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/OpenSIPS/opensips/pull/345.patch'>https://github.com/OpenSIPS/opensips/pull/345.patch</a></li>
  <li><a href='https://github.com/OpenSIPS/opensips/pull/345.diff'>https://github.com/OpenSIPS/opensips/pull/345.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/pull/345">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/5479561__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyNzc5NDU1MywiZGF0YSI6eyJpZCI6NDQ0NDI0ODV9fQ==--b05c4d9139855c5c780f7778312e8466dd5d4e67.gif" width="1" /></p>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"View this Pull Request on GitHub","action":{"@type":"ViewAction","url":"https://github.com/OpenSIPS/opensips/pull/345","name":"View Pull Request"}}</script>