diff --git a/engine/filters.go b/engine/filters.go index 4e0797a12..465ec2c13 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -736,3 +736,14 @@ func (fltr *Filter) Compress() { } fltr.Rules = newRules } + +func (fltr *Filter) Merge(v2 interface{}) { + vi := v2.(*Filter) + if len(vi.Tenant) != 0 { + fltr.Tenant = vi.Tenant + } + if len(vi.ID) != 0 { + fltr.ID = vi.ID + } + fltr.Rules = append(fltr.Rules, vi.Rules...) +} diff --git a/engine/libattributes.go b/engine/libattributes.go index 21fc7cf7b..8b893e167 100644 --- a/engine/libattributes.go +++ b/engine/libattributes.go @@ -234,3 +234,21 @@ func (ap *AttributeProfile) Set(path []string, val interface{}, newBranch bool, } return } + +func (ap *AttributeProfile) Merge(v2 interface{}) { + vi := v2.(*AttributeProfile) + if len(vi.Tenant) != 0 { + ap.Tenant = vi.Tenant + } + if len(vi.ID) != 0 { + ap.ID = vi.ID + } + ap.FilterIDs = append(ap.FilterIDs, vi.FilterIDs...) + ap.Attributes = append(ap.Attributes, vi.Attributes...) + if vi.Blocker { + ap.Blocker = true + } + if vi.Weight != 0 { + ap.Weight = vi.Weight + } +} diff --git a/engine/libstats.go b/engine/libstats.go index 43da7492a..e975579b9 100644 --- a/engine/libstats.go +++ b/engine/libstats.go @@ -598,3 +598,35 @@ func (sqp *StatQueueProfile) Set(path []string, val interface{}, newBranch bool, } return } + +func (sqp *StatQueueProfile) Merge(v2 interface{}) { + vi := v2.(*StatQueueProfile) + if len(vi.Tenant) != 0 { + sqp.Tenant = vi.Tenant + } + if len(vi.ID) != 0 { + sqp.ID = vi.ID + } + sqp.FilterIDs = append(sqp.FilterIDs, vi.FilterIDs...) + sqp.ThresholdIDs = append(sqp.ThresholdIDs, vi.ThresholdIDs...) + sqp.Metrics = append(sqp.Metrics, vi.Metrics...) + + if vi.QueueLength != 0 { + sqp.QueueLength = vi.QueueLength + } + if vi.TTL != 0 { + sqp.TTL = vi.TTL + } + if vi.MinItems != 0 { + sqp.MinItems = vi.MinItems + } + if vi.Blocker { + sqp.Blocker = vi.Blocker + } + if vi.Stored { + sqp.Stored = vi.Stored + } + if vi.Weight != 0 { + sqp.Weight = vi.Weight + } +} diff --git a/engine/resources.go b/engine/resources.go index a355dbaa7..780c1fd8d 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -1056,3 +1056,33 @@ func (rp *ResourceProfile) Set(path []string, val interface{}, _ bool, _ string) } return } + +func (rp *ResourceProfile) Merge(v2 interface{}) { + vi := v2.(*ResourceProfile) + if len(vi.Tenant) != 0 { + rp.Tenant = vi.Tenant + } + if len(vi.ID) != 0 { + rp.ID = vi.ID + } + rp.FilterIDs = append(rp.FilterIDs, vi.FilterIDs...) + rp.ThresholdIDs = append(rp.ThresholdIDs, vi.ThresholdIDs...) + if len(vi.AllocationMessage) != 0 { + rp.AllocationMessage = vi.AllocationMessage + } + if vi.UsageTTL != 0 { + rp.UsageTTL = vi.UsageTTL + } + if vi.Limit != 0 { + rp.Limit = vi.Limit + } + if vi.Blocker { + rp.Blocker = vi.Blocker + } + if vi.Stored { + rp.Stored = vi.Stored + } + if vi.Weight != 0 { + rp.Weight = vi.Weight + } +} diff --git a/engine/routes.go b/engine/routes.go index 3e70dbc80..5a7f22b1d 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -526,3 +526,20 @@ func (rp *RouteProfile) Set(path []string, val interface{}, newBranch bool, _ st } return } + +func (rp *RouteProfile) Merge(v2 interface{}) { + vi := v2.(*RouteProfile) + if len(vi.Tenant) != 0 { + rp.Tenant = vi.Tenant + } + if len(vi.ID) != 0 { + rp.ID = vi.ID + } + rp.FilterIDs = append(rp.FilterIDs, vi.FilterIDs...) + rp.SortingParameters = append(rp.SortingParameters, vi.SortingParameters...) + rp.Routes = append(rp.Routes, vi.Routes...) + rp.Weights = append(rp.Weights, vi.Weights...) + if len(vi.Sorting) != 0 { + rp.Sorting = vi.Sorting + } +} diff --git a/engine/thresholds.go b/engine/thresholds.go index 385cf2fb7..5f3055605 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -625,3 +625,33 @@ func (tp *ThresholdProfile) Set(path []string, val interface{}, _ bool, _ string } return } + +func (tp *ThresholdProfile) Merge(v2 interface{}) { + vi := v2.(*ThresholdProfile) + if len(vi.Tenant) != 0 { + tp.Tenant = vi.Tenant + } + if len(vi.ID) != 0 { + tp.ID = vi.ID + } + tp.FilterIDs = append(tp.FilterIDs, vi.FilterIDs...) + tp.ActionProfileIDs = append(tp.ActionProfileIDs, vi.ActionProfileIDs...) + if vi.Blocker { + tp.Blocker = vi.Blocker + } + if vi.Async { + tp.Async = vi.Async + } + if vi.Weight != 0 { + tp.Weight = vi.Weight + } + if vi.MaxHits != 0 { + tp.MaxHits = vi.MaxHits + } + if vi.MinHits != 0 { + tp.MinHits = vi.MinHits + } + if vi.MinSleep != 0 { + tp.MinSleep = vi.MinSleep + } +}