mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add RemoveActions in DataManager
This commit is contained in:
committed by
Dan Christian Bogos
parent
1546720116
commit
35ad39685e
@@ -1709,7 +1709,7 @@ func (self *ApierV1) RemoveActions(attr AttrRemoveActions, reply *string) error
|
||||
}
|
||||
*/
|
||||
for _, aID := range attr.ActionIDs {
|
||||
if err := self.DataManager.DataDB().RemoveActions(aID, utils.NonTransactional); err != nil {
|
||||
if err := self.DataManager.RemoveActions(aID, utils.NonTransactional); err != nil {
|
||||
*reply = err.Error()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -656,3 +656,11 @@ func (dm *DataManager) SetActions(key string, as Actions, transactionID string)
|
||||
return dm.DataDB().SetActionsDrv(key, as)
|
||||
}
|
||||
}
|
||||
|
||||
func (dm *DataManager) RemoveActions(key, transactionID string) (err error) {
|
||||
if err = dm.DataDB().RemoveActionsDrv(key); err != nil {
|
||||
return
|
||||
}
|
||||
cache.RemKey(utils.ACTION_PREFIX+key, cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1335,7 +1335,7 @@ func testOnStorITCRUDActions(t *testing.T) {
|
||||
// t.Error(err)
|
||||
// }
|
||||
|
||||
if err := onStor.DataDB().RemoveActions(acts[0].Id, utils.NonTransactional); err != nil {
|
||||
if err := onStor.RemoveActions(acts[0].Id, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, rcvErr := onStor.GetActions(acts[0].Id, true, utils.NonTransactional); rcvErr != utils.ErrNotFound {
|
||||
|
||||
@@ -68,7 +68,7 @@ type DataDB interface {
|
||||
SetDerivedChargers(string, *utils.DerivedChargers, string) error
|
||||
GetActionsDrv(string) (Actions, error)
|
||||
SetActionsDrv(string, Actions) error
|
||||
RemoveActions(string, string) error
|
||||
RemoveActionsDrv(string) error
|
||||
GetSharedGroupDrv(string) (*SharedGroup, error)
|
||||
SetSharedGroupDrv(*SharedGroup) error
|
||||
GetActionTriggersDrv(string) (ActionTriggers, error)
|
||||
|
||||
@@ -492,12 +492,11 @@ func (ms *MapStorage) SetActionsDrv(key string, as Actions) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ms *MapStorage) RemoveActions(key string, transactionID string) (err error) {
|
||||
func (ms *MapStorage) RemoveActionsDrv(key string) (err error) {
|
||||
cachekey := utils.ACTION_PREFIX + key
|
||||
ms.mu.Lock()
|
||||
delete(ms.dict, cachekey)
|
||||
ms.mu.Unlock()
|
||||
cache.RemKey(cachekey, cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -984,11 +984,10 @@ func (ms *MongoStorage) SetActionsDrv(key string, as Actions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (ms *MongoStorage) RemoveActions(key string, transactionID string) error {
|
||||
func (ms *MongoStorage) RemoveActionsDrv(key string) error {
|
||||
session, col := ms.conn(colAct)
|
||||
defer session.Close()
|
||||
err := col.Remove(bson.M{"key": key})
|
||||
cache.RemKey(utils.ACTION_PREFIX+key, cacheCommit(transactionID), transactionID)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -540,9 +540,8 @@ func (rs *RedisStorage) SetActionsDrv(key string, as Actions) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (rs *RedisStorage) RemoveActions(key string, transactionID string) (err error) {
|
||||
func (rs *RedisStorage) RemoveActionsDrv(key string) (err error) {
|
||||
err = rs.Cmd("DEL", utils.ACTION_PREFIX+key).Err
|
||||
cache.RemKey(utils.ACTION_PREFIX+key, cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user