mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
Add SetThresholdProfile in Datamanger
This commit is contained in:
committed by
Dan Christian Bogos
parent
05b8001857
commit
1b722f29bb
@@ -77,7 +77,7 @@ func (apierV1 *ApierV1) SetThresholdProfile(thp *engine.ThresholdProfile, reply
|
||||
if missing := utils.MissingStructFields(thp, []string{"Tenant", "ID"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if err := apierV1.DataManager.DataDB().SetThresholdProfile(thp); err != nil {
|
||||
if err := apierV1.DataManager.SetThresholdProfile(thp); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
cache.RemKey(utils.ThresholdProfilePrefix+utils.ConcatenatedKey(thp.Tenant, thp.ID), true, "") // ToDo: Remove here with autoreload
|
||||
|
||||
@@ -166,5 +166,8 @@ func (dm *DataManager) GetThresholdProfile(tenant, id string, skipCache bool, tr
|
||||
}
|
||||
cache.Set(key, th, cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (dm *DataManager) SetThresholdProfile(th *ThresholdProfile) (err error) {
|
||||
return dm.DataDB().SetThresholdProfileDrv(th)
|
||||
}
|
||||
|
||||
@@ -2066,7 +2066,7 @@ func testOnStorITCRUDThresholdProfile(t *testing.T) {
|
||||
false, utils.NonTransactional); rcvErr != utils.ErrNotFound {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
if err := onStor.DataDB().SetThresholdProfile(th); err != nil {
|
||||
if err := onStor.SetThresholdProfile(th); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.GetThresholdProfile(th.Tenant, th.ID, true, utils.NonTransactional); err != nil {
|
||||
|
||||
@@ -121,7 +121,7 @@ type DataDB interface {
|
||||
SetStoredStatQueue(sq *StoredStatQueue) (err error)
|
||||
RemStoredStatQueue(tenant, id string) (err error)
|
||||
GetThresholdProfileDrv(tenant string, ID string) (tp *ThresholdProfile, err error)
|
||||
SetThresholdProfile(tp *ThresholdProfile) (err error)
|
||||
SetThresholdProfileDrv(tp *ThresholdProfile) (err error)
|
||||
RemThresholdProfile(tenant, id, transactionID string) (err error)
|
||||
GetThresholdDrv(string, string) (*Threshold, error)
|
||||
SetThresholdDrv(*Threshold) error
|
||||
|
||||
@@ -1591,8 +1591,8 @@ func (ms *MapStorage) GetThresholdProfileDrv(tenant, ID string) (tp *ThresholdPr
|
||||
return
|
||||
}
|
||||
|
||||
// SetThresholdProfile stores a ThresholdProfile into DataDB
|
||||
func (ms *MapStorage) SetThresholdProfile(tp *ThresholdProfile) (err error) {
|
||||
// SetThresholdProfileDrv stores a ThresholdProfile into DataDB
|
||||
func (ms *MapStorage) SetThresholdProfileDrv(tp *ThresholdProfile) (err error) {
|
||||
ms.mu.Lock()
|
||||
defer ms.mu.Unlock()
|
||||
result, err := ms.ms.Marshal(tp)
|
||||
|
||||
@@ -2176,8 +2176,8 @@ func (ms *MongoStorage) GetThresholdProfileDrv(tenant, ID string) (tp *Threshold
|
||||
return
|
||||
}
|
||||
|
||||
// SetThresholdProfile stores a ThresholdProfile into DataDB
|
||||
func (ms *MongoStorage) SetThresholdProfile(tp *ThresholdProfile) (err error) {
|
||||
// SetThresholdProfileDrv stores a ThresholdProfile into DataDB
|
||||
func (ms *MongoStorage) SetThresholdProfileDrv(tp *ThresholdProfile) (err error) {
|
||||
session, col := ms.conn(colTps)
|
||||
defer session.Close()
|
||||
_, err = col.UpsertId(bson.M{"tenant": tp.Tenant, "id": tp.ID}, tp)
|
||||
|
||||
@@ -1684,7 +1684,7 @@ func (rs *RedisStorage) RemStoredStatQueue(tenant, id string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetThresholdProfile retrieves a ThresholdProfile from dataDB
|
||||
// GetThresholdProfileDrv retrieves a ThresholdProfile from dataDB
|
||||
func (rs *RedisStorage) GetThresholdProfileDrv(tenant, ID string) (tp *ThresholdProfile, err error) {
|
||||
key := utils.ThresholdProfilePrefix + utils.ConcatenatedKey(tenant, ID)
|
||||
var values []byte
|
||||
@@ -1705,8 +1705,8 @@ func (rs *RedisStorage) GetThresholdProfileDrv(tenant, ID string) (tp *Threshold
|
||||
return
|
||||
}
|
||||
|
||||
// SetThresholdProfile stores a ThresholdProfile into DataDB
|
||||
func (rs *RedisStorage) SetThresholdProfile(tp *ThresholdProfile) (err error) {
|
||||
// SetThresholdProfileDrv stores a ThresholdProfile into DataDB
|
||||
func (rs *RedisStorage) SetThresholdProfileDrv(tp *ThresholdProfile) (err error) {
|
||||
var result []byte
|
||||
result, err = rs.ms.Marshal(tp)
|
||||
if err != nil {
|
||||
|
||||
@@ -2086,7 +2086,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = tpr.dm.DataDB().SetThresholdProfile(th); err != nil {
|
||||
if err = tpr.dm.SetThresholdProfile(th); err != nil {
|
||||
return err
|
||||
}
|
||||
if verbose {
|
||||
|
||||
Reference in New Issue
Block a user