Add support for *internal as dataDB and storDB

This commit is contained in:
TeoV
2018-07-02 06:08:17 -04:00
committed by Dan Christian Bogos
parent eee8390319
commit 85f73f2773
6 changed files with 115 additions and 24 deletions

View File

@@ -0,0 +1,70 @@
{
// CGRateS Configuration file
"general": {
"log_level": 7,
"reply_timeout": "30s",
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": {
"db_type": "*internal",
},
"stor_db": {
"db_type": "*internal",
},
"cache":{
"destinations": {"limit": 10000, "ttl":"0s", "precache": true},
"reverse_destinations": {"limit": 10000, "ttl":"0s", "precache": true},
"rating_plans": {"limit": 10000, "ttl":"0s","precache": true},
"rating_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"lcr_rules": {"limit": 10000, "ttl":"0s", "precache": true},
"cdr_stats": {"limit": 10000, "ttl":"0s", "precache": true},
"actions": {"limit": 10000, "ttl":"0s", "precache": true},
"action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
"aliases": {"limit": 10000, "ttl":"0s", "precache": true},
"reverse_aliases": {"limit": 10000, "ttl":"0s", "precache": true},
"derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueue_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"thresholds": {"limit": 10000, "ttl":"0s", "precache": true},
"threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"filters": {"limit": 10000, "ttl":"0s", "precache": true},
"supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"attribute_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_filter_indexes" :{"limit": 10000, "ttl":"0s"},
"resource_filter_revindexes" : {"limit": 10000, "ttl":"0s"},
"stat_filter_indexes" : {"limit": 10000, "ttl":"0s"},
"stat_filter_revindexes" : {"limit": 10000, "ttl":"0s"},
"threshold_filter_indexes" : {"limit": 10000, "ttl":"0s"},
"threshold_filter_revindexes" : {"limit": 10000, "ttl":"0s"},
"supplier_filter_indexes" : {"limit": 10000, "ttl":"0s"},
"supplier_filter_revindexes" :{"limit": 10000, "ttl":"0s"},
"attribute_filter_indexes" : {"limit": 10000, "ttl":"0s"},
"attribute_filter_revindexes" : {"limit": 10000, "ttl":"0s"},
},
"rals": {
"enabled": true,
},
}

View File

@@ -1664,8 +1664,6 @@ func (ms *MapStorage) GetVersions(itm string) (vrs Versions, err error) {
}
func (ms *MapStorage) SetVersions(vrs Versions, overwrite bool) (err error) {
ms.mu.Lock()
defer ms.mu.Unlock()
var result []byte
var x Versions
if !overwrite {
@@ -1673,7 +1671,7 @@ func (ms *MapStorage) SetVersions(vrs Versions, overwrite bool) (err error) {
if err != nil {
return err
}
for key, _ := range vrs {
for key := range vrs {
if x[key] != vrs[key] {
x[key] = vrs[key]
}
@@ -1682,19 +1680,22 @@ func (ms *MapStorage) SetVersions(vrs Versions, overwrite bool) (err error) {
if err != nil {
return err
}
ms.mu.Lock()
ms.dict[utils.TBLVersions] = result
return
} else {
result, err = ms.ms.Marshal(vrs)
if err != nil {
return err
}
if ms.RemoveVersions(vrs); err != nil {
return err
}
ms.dict[utils.TBLVersions] = result
ms.mu.Unlock()
return
}
result, err = ms.ms.Marshal(vrs)
if err != nil {
return err
}
if ms.RemoveVersions(vrs); err != nil {
return err
}
ms.mu.Lock()
ms.dict[utils.TBLVersions] = result
ms.mu.Unlock()
return
}
func (ms *MapStorage) RemoveVersions(vrs Versions) (err error) {

View File

@@ -181,3 +181,7 @@ func (ms *MapStorage) RemoveSMCost(smc *SMCost) (err error) {
func (ms *MapStorage) GetCDRs(filter *utils.CDRsFilter, remove bool) (cdrs []*CDR, count int64, err error) {
return
}
func (ms *MapStorage) GetSMCosts(cgrid, runid, originHost, originIDPrfx string) (smCosts []*SMCost, err error) {
return
}

View File

@@ -49,9 +49,16 @@ func ConfigureDataStorage(db_type, host, port, name, user, pass, marshaler strin
case utils.MONGO:
d, err = NewMongoStorage(host, port, name, user, pass, utils.DataDB, nil, cacheCfg, loadHistorySize)
dm = NewDataManager(d.(DataDB))
case utils.MetaInternal:
if marshaler == utils.JSON {
d, err = NewMapStorageJson()
} else {
d, err = NewMapStorage()
}
dm = NewDataManager(d.(DataDB))
default:
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are '%s' or '%s'",
db_type, utils.REDIS, utils.MONGO))
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are '%s' or '%s or '%s'",
db_type, utils.REDIS, utils.MONGO, utils.MetaInternal))
}
if err != nil {
return nil, err
@@ -69,9 +76,11 @@ func ConfigureStorStorage(db_type, host, port, name, user, pass, marshaler strin
d, err = NewPostgresStorage(host, port, name, user, pass, maxConn, maxIdleConn, connMaxLifetime)
case utils.MYSQL:
d, err = NewMySQLStorage(host, port, name, user, pass, maxConn, maxIdleConn, connMaxLifetime)
case utils.MetaInternal:
d, err = NewMapStorage()
default:
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES))
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES, utils.MetaInternal))
}
if err != nil {
return nil, err
@@ -89,9 +98,11 @@ func ConfigureLoadStorage(db_type, host, port, name, user, pass, marshaler strin
d, err = NewMySQLStorage(host, port, name, user, pass, maxConn, maxIdleConn, connMaxLifetime)
case utils.MONGO:
d, err = NewMongoStorage(host, port, name, user, pass, utils.StorDB, cdrsIndexes, nil, 1)
case utils.MetaInternal:
d, err = NewMapStorage()
default:
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES))
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES, utils.MetaInternal))
}
if err != nil {
return nil, err
@@ -109,9 +120,11 @@ func ConfigureCdrStorage(db_type, host, port, name, user, pass string,
d, err = NewMySQLStorage(host, port, name, user, pass, maxConn, maxIdleConn, connMaxLifetime)
case utils.MONGO:
d, err = NewMongoStorage(host, port, name, user, pass, utils.StorDB, cdrsIndexes, nil, 1)
case utils.INTERNAL:
d, err = NewMapStorage()
default:
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES))
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES, utils.INTERNAL))
}
if err != nil {
return nil, err
@@ -129,9 +142,11 @@ func ConfigureStorDB(db_type, host, port, name, user, pass string,
d, err = NewMySQLStorage(host, port, name, user, pass, maxConn, maxIdleConn, connMaxLifetime)
case utils.MONGO:
d, err = NewMongoStorage(host, port, name, user, pass, utils.StorDB, cdrsIndexes, nil, 1)
case utils.INTERNAL:
d, err = NewMapStorage()
default:
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES))
err = errors.New(fmt.Sprintf("Unknown db '%s' valid options are [%s, %s, %s, %s]",
db_type, utils.MYSQL, utils.MONGO, utils.POSTGRES, utils.INTERNAL))
}
if err != nil {
return nil, err

View File

@@ -190,7 +190,7 @@ func CurrentDBVersions(storType string) Versions {
}
switch storType {
case utils.MONGO, utils.MAPSTOR:
case utils.MONGO, utils.MAPSTOR, utils.INTERNAL:
return allVersions
case utils.POSTGRES, utils.MYSQL:
return storDbVersions

View File

@@ -107,6 +107,7 @@ const (
DataManager = "DataManager"
REDIS = "redis"
MAPSTOR = "mapstor"
INTERNAL = "internal"
LOCALHOST = "127.0.0.1"
FSCDR_FILE_CSV = "freeswitch_file_csv"
FSCDR_HTTP_JSON = "freeswitch_http_json"