mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
use weight in destination matching
This commit is contained in:
@@ -37,7 +37,7 @@ Strategy indicates supplier selection algorithm and StrategyParams will be speci
|
||||
|
||||
ActivationTime is the date/time when the LCR entry starts to be active.
|
||||
|
||||
Weight is used to further sort the rules. It passed untouched and unused by the system for the session manager use only.
|
||||
Weight is used to sort the rules with the same activation time.
|
||||
|
||||
Example
|
||||
+++++++
|
||||
@@ -64,8 +64,8 @@ For the lowest/highest cost strategies the matched suppliers are sorted ascendin
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"Entry": {
|
||||
{
|
||||
"Entry": {
|
||||
"DestinationId": "*any",
|
||||
"RPCategory": "LCR_STANDARD",
|
||||
"Strategy": "*lowest_cost",
|
||||
@@ -73,6 +73,6 @@ For the lowest/highest cost strategies the matched suppliers are sorted ascendin
|
||||
"Weight": 20
|
||||
},
|
||||
"SupplierCosts": [{"Supplier":"rif", Cost:"2.0"},{"Supplier":"dan", Cost:"1.0"}]
|
||||
}
|
||||
}
|
||||
|
||||
.. [WIKI2015] http://en.wikipedia.org/wiki/Least-cost_routing
|
||||
|
||||
@@ -140,8 +140,8 @@ func (es LCREntriesSorter) Swap(i, j int) {
|
||||
}
|
||||
|
||||
func (es LCREntriesSorter) Less(j, i int) bool {
|
||||
return es[i].precision < es[j].precision ||
|
||||
(es[i].precision == es[j].precision && es[i].Weight < es[j].Weight)
|
||||
return es[i].Weight < es[j].Weight ||
|
||||
(es[i].Weight == es[j].Weight && es[i].precision < es[j].precision)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package engine
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -185,8 +183,8 @@ func TestLcrGet(t *testing.T) {
|
||||
Subject: "rif",
|
||||
}
|
||||
lcr, err := cd.GetLCR(nil)
|
||||
jsn, _ := json.Marshal(lcr)
|
||||
log.Print("LCR: ", string(jsn))
|
||||
//jsn, _ := json.Marshal(lcr)
|
||||
//log.Print("LCR: ", string(jsn))
|
||||
if err != nil || lcr == nil {
|
||||
t.Errorf("Bad lcr: %+v, %v", lcr, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user