diff --git a/apier/v1/accounts.go b/apier/v1/accounts.go index 427d4f957..b4dc192f8 100644 --- a/apier/v1/accounts.go +++ b/apier/v1/accounts.go @@ -79,7 +79,7 @@ func (self *ApierV1) RemActionTiming(attrs AttrRemActionTiming, reply *string) e return utils.NewErrMandatoryIeMissing(missing...) } } - _, err := engine.AccLock.Guard(func() (interface{}, error) { + _, err := engine.Guardian.Guard(func() (interface{}, error) { ats, err := self.RatingDb.GetActionPlans(attrs.ActionPlanId) if err != nil { return 0, err @@ -129,7 +129,7 @@ func (self *ApierV1) RemAccountActionTriggers(attrs AttrRemAcntActionTriggers, r return utils.NewErrMandatoryIeMissing(missing...) } balanceId := utils.AccountKey(attrs.Tenant, attrs.Account, attrs.Direction) - _, err := engine.AccLock.Guard(func() (interface{}, error) { + _, err := engine.Guardian.Guard(func() (interface{}, error) { ub, err := self.AccountDb.GetAccount(balanceId) if err != nil { return 0, err @@ -162,7 +162,7 @@ func (self *ApierV1) SetAccount(attr utils.AttrSetAccount, reply *string) error balanceId := utils.AccountKey(attr.Tenant, attr.Account, attr.Direction) var ub *engine.Account var ats engine.ActionPlans - _, err := engine.AccLock.Guard(func() (interface{}, error) { + _, err := engine.Guardian.Guard(func() (interface{}, error) { if bal, _ := self.AccountDb.GetAccount(balanceId); bal != nil { ub = bal } else { // Not found in db, create it here @@ -192,7 +192,7 @@ func (self *ApierV1) SetAccount(attr utils.AttrSetAccount, reply *string) error return utils.NewErrServerError(err) } if len(ats) != 0 { - _, err := engine.AccLock.Guard(func() (interface{}, error) { // ToDo: Try locking it above on read somehow + _, err := engine.Guardian.Guard(func() (interface{}, error) { // ToDo: Try locking it above on read somehow if err := self.RatingDb.SetActionPlans(attr.ActionPlanId, ats); err != nil { return 0, err } diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 03f27f28f..d7cc578ef 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -732,7 +732,7 @@ func (self *ApierV1) AddTriggeredAction(attr AttrAddActionTrigger, reply *string } tag := utils.AccountKey(attr.Tenant, attr.Account, attr.BalanceDirection) - _, err = engine.AccLock.Guard(func() (interface{}, error) { + _, err = engine.Guardian.Guard(func() (interface{}, error) { userBalance, err := self.AccountDb.GetAccount(tag) if err != nil { return 0, err @@ -802,7 +802,7 @@ func (self *ApierV1) ResetTriggeredActions(attr AttrResetTriggeredAction, reply } } accID := utils.AccountKey(attr.Tenant, attr.Account, attr.Direction) - _, err := engine.AccLock.Guard(func() (interface{}, error) { + _, err := engine.Guardian.Guard(func() (interface{}, error) { acc, err := self.AccountDb.GetAccount(accID) if err != nil { return 0, err @@ -829,7 +829,7 @@ func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *str return utils.NewErrMandatoryIeMissing("TPid") } dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid) - if _, err := engine.AccLock.Guard(func() (interface{}, error) { + if _, err := engine.Guardian.Guard(func() (interface{}, error) { aas := engine.APItoModelAccountAction(&attrs) if err := dbReader.LoadAccountActionsFiltered(aas); err != nil { return 0, err diff --git a/apier/v2/apier.go b/apier/v2/apier.go index 5a64dfb57..80e05bf06 100644 --- a/apier/v2/apier.go +++ b/apier/v2/apier.go @@ -71,7 +71,7 @@ func (self *ApierV2) LoadAccountActions(attrs AttrLoadAccountActions, reply *str tpAa := &utils.TPAccountActions{TPid: attrs.TPid} tpAa.SetAccountActionsId(attrs.AccountActionsId) aa := engine.APItoModelAccountAction(tpAa) - if _, err := engine.AccLock.Guard(func() (interface{}, error) { + if _, err := engine.Guardian.Guard(func() (interface{}, error) { if err := dbReader.LoadAccountActionsFiltered(aa); err != nil { return 0, err } diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index 86b61715f..668e83007 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -108,7 +108,7 @@ func (s *Scheduler) LoadActionPlans(storage engine.RatingStorage) { newAts = append(newAts, at) } if toBeSaved { - engine.AccLock.Guard(func() (interface{}, error) { + engine.Guardian.Guard(func() (interface{}, error) { storage.SetActionPlans(key, newAts) return 0, nil }, utils.ACTION_TIMING_PREFIX)