diff --git a/docs/lcr.rst b/docs/lcr.rst index 527c53bfd..e96f7750b 100644 --- a/docs/lcr.rst +++ b/docs/lcr.rst @@ -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 diff --git a/engine/lcr.go b/engine/lcr.go index f3206dda1..5e916391b 100644 --- a/engine/lcr.go +++ b/engine/lcr.go @@ -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) } diff --git a/engine/lcr_test.go b/engine/lcr_test.go index 3cd7d43a2..1360079e7 100644 --- a/engine/lcr_test.go +++ b/engine/lcr_test.go @@ -19,8 +19,6 @@ along with this program. If not, see 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) }