mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-16 13:49:53 +05:00
Update match functions for dispatcher profiles
This commit is contained in:
committed by
Dan Christian Bogos
parent
f562066ee9
commit
30e419429d
@@ -311,7 +311,20 @@ func (dP *DispatcherProfile) Merge(v2 interface{}) {
|
||||
dP.ID = vi.ID
|
||||
}
|
||||
dP.FilterIDs = append(dP.FilterIDs, vi.FilterIDs...)
|
||||
dP.Hosts = append(dP.Hosts, vi.Hosts...)
|
||||
var equal bool
|
||||
for _, hostV2 := range vi.Hosts {
|
||||
for _, host := range dP.Hosts {
|
||||
if host.ID == hostV2.ID {
|
||||
host.Merge(hostV2)
|
||||
equal = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !equal {
|
||||
dP.Hosts = append(dP.Hosts, hostV2)
|
||||
}
|
||||
}
|
||||
// dP.Hosts = append(dP.Hosts, vi.Hosts...)
|
||||
if vi.Weight != 0 {
|
||||
dP.Weight = vi.Weight
|
||||
}
|
||||
@@ -323,6 +336,22 @@ func (dP *DispatcherProfile) Merge(v2 interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (dspHost *DispatcherHostProfile) Merge(v2 *DispatcherHostProfile) {
|
||||
if v2.ID != utils.EmptyString {
|
||||
dspHost.ID = v2.ID
|
||||
}
|
||||
if v2.Weight != 0 {
|
||||
dspHost.Weight = v2.Weight
|
||||
}
|
||||
if v2.Blocker {
|
||||
dspHost.Blocker = v2.Blocker
|
||||
}
|
||||
dspHost.FilterIDs = append(dspHost.FilterIDs, v2.FilterIDs...)
|
||||
for k, v := range v2.Params {
|
||||
dspHost.Params[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
func (dH *DispatcherHost) Merge(v2 interface{}) {
|
||||
vi := v2.(*DispatcherHost)
|
||||
if len(vi.Tenant) != 0 {
|
||||
|
||||
@@ -1042,7 +1042,9 @@ func (rp *ResourceProfile) Set(path []string, val interface{}, _ bool, _ string)
|
||||
case utils.UsageTTL:
|
||||
rp.UsageTTL, err = utils.IfaceAsDuration(val)
|
||||
case utils.Limit:
|
||||
rp.Limit, err = utils.IfaceAsFloat64(val)
|
||||
if val != utils.EmptyString {
|
||||
rp.Limit, err = utils.IfaceAsFloat64(val)
|
||||
}
|
||||
case utils.AllocationMessage:
|
||||
rp.AllocationMessage = utils.IfaceAsString(val)
|
||||
case utils.Blocker:
|
||||
|
||||
@@ -602,8 +602,8 @@ func (rp *RateProfile) Set(path []string, val interface{}, newBranch bool, _ str
|
||||
valA, err = IfaceAsStringSlice(val)
|
||||
rp.FilterIDs = append(rp.FilterIDs, valA...)
|
||||
case Weights:
|
||||
if weights := IfaceAsString(val); weights != EmptyString {
|
||||
rp.Weights, err = NewDynamicWeightsFromString(weights, InfieldSep, ANDSep)
|
||||
if val != EmptyString {
|
||||
rp.Weights, err = NewDynamicWeightsFromString(IfaceAsString(val), InfieldSep, ANDSep)
|
||||
}
|
||||
case MinCost:
|
||||
if val != EmptyString {
|
||||
@@ -639,8 +639,8 @@ func (rt *Rate) Set(path []string, val interface{}, newBranch bool) (err error)
|
||||
valA, err = IfaceAsStringSlice(val)
|
||||
rt.FilterIDs = append(rt.FilterIDs, valA...)
|
||||
case Weights:
|
||||
if weights := IfaceAsString(val); weights != EmptyString {
|
||||
rt.Weights, err = NewDynamicWeightsFromString(weights, InfieldSep, ANDSep)
|
||||
if val != EmptyString {
|
||||
rt.Weights, err = NewDynamicWeightsFromString(IfaceAsString(val), InfieldSep, ANDSep)
|
||||
}
|
||||
case ActivationTimes:
|
||||
rt.ActivationTimes = IfaceAsString(val)
|
||||
|
||||
Reference in New Issue
Block a user