Model converters, instantiate Usage on resourceLimit

This commit is contained in:
DanB
2016-08-07 17:00:14 +02:00
parent 5eb61216f2
commit f8a998600b
3 changed files with 4 additions and 4 deletions

View File

@@ -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>
},

View File

@@ -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 {

View File

@@ -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"},