mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-13 11:06:25 +05:00
Model converters, instantiate Usage on resourceLimit
This commit is contained in:
@@ -386,8 +386,8 @@ const CGRATES_CFG_JSON = `
|
||||
"rls": {
|
||||
"enabled": false, // starts ResourceLimiter service: <true|false>.
|
||||
"cdrstats_conns": [], // address where to reach the cdrstats service, empty to disable stats functionality: <""|*internal|x.y.z.y:1234>
|
||||
"cache_dump_interval": "0s", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|*never|dur>
|
||||
"usage_ttl": "3h", // expire usage records if older than this duration <""|*never|dur>
|
||||
"cache_dump_interval": "0s", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|*never|$dur>
|
||||
"usage_ttl": "3h", // expire usage records if older than this duration <""|*never|$dur>
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ func APItoModelUsers(attr *utils.TPUsers) (result []TpUser) {
|
||||
}
|
||||
|
||||
func APItoResourceLimit(tpRL *utils.TPResourceLimit, timezone string) (rl *ResourceLimit, err error) {
|
||||
rl = &ResourceLimit{ID: tpRL.ID, Weight: tpRL.Weight, Filters: make([]*RequestFilter, len(tpRL.Filters))}
|
||||
rl = &ResourceLimit{ID: tpRL.ID, Weight: tpRL.Weight, Filters: make([]*RequestFilter, len(tpRL.Filters)), Usage: make(map[string]*ResourceUsage)}
|
||||
for i, tpFltr := range tpRL.Filters {
|
||||
rf := &RequestFilter{Type: tpFltr.Type, FieldName: tpFltr.FieldName, Values: tpFltr.Values}
|
||||
if err := rf.CompileValues(); err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestAPItoResourceLimit(t *testing.T) {
|
||||
Weight: 10,
|
||||
Limit: "2",
|
||||
}
|
||||
eRL := &ResourceLimit{ID: tpRL.ID, Weight: tpRL.Weight, Filters: make([]*RequestFilter, len(tpRL.Filters))}
|
||||
eRL := &ResourceLimit{ID: tpRL.ID, Weight: tpRL.Weight, Filters: make([]*RequestFilter, len(tpRL.Filters)), Usage: make(map[string]*ResourceUsage)}
|
||||
eRL.Filters[0] = &RequestFilter{Type: MetaString, FieldName: "Account", Values: []string{"1001", "1002"}}
|
||||
eRL.Filters[1] = &RequestFilter{Type: MetaStringPrefix, FieldName: "Destination", Values: []string{"10", "20"}}
|
||||
eRL.Filters[2] = &RequestFilter{Type: MetaCDRStats, Values: []string{"CDRST1:*min_ASR:34", "CDRST_1001:*min_ASR:20"},
|
||||
|
||||
Reference in New Issue
Block a user