diff --git a/apier/apier_local_test.go b/apier/apier_local_test.go index eb3a2a3fa..136e51b35 100644 --- a/apier/apier_local_test.go +++ b/apier/apier_local_test.go @@ -1277,7 +1277,7 @@ func TestResetDataAfterLoadFromFolder(t *testing.T) { t.Error("Calling ApierV1.ReloadCache got reply: ", reply) } var rcvStats *utils.CacheStats - expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 3, RatingProfiles: 3, Actions: 4, DerivedChargers: 2} + expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 3, RatingProfiles: 3, Actions: 5, DerivedChargers: 2} var args utils.AttrCacheStats if err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil { t.Error("Got error on ApierV1.GetCacheStats: ", err.Error()) diff --git a/engine/cdrs.go b/engine/cdrs.go index fecd96ec6..b10766712 100644 --- a/engine/cdrs.go +++ b/engine/cdrs.go @@ -36,6 +36,11 @@ var ( // Returns error if not able to properly store the CDR, mediation is async since we can always recover offline func storeAndMediate(storedCdr *utils.StoredCdr) error { + if !cfg.CDRSStoreDisable { + if err := storage.SetCdr(storedCdr); err != nil { + return err + } + } if stats != nil { go func() { if err := stats.AppendCDR(storedCdr, nil); err != nil { @@ -43,9 +48,6 @@ func storeAndMediate(storedCdr *utils.StoredCdr) error { } }() } - if err := storage.SetCdr(storedCdr); err != nil { - return err - } if cfg.CDRSMediator == utils.INTERNAL { go func() { if err := medi.RateCdr(storedCdr, true); err != nil { diff --git a/engine/mediator.go b/engine/mediator.go index 2f00c1502..d7eb3a4d3 100644 --- a/engine/mediator.go +++ b/engine/mediator.go @@ -168,9 +168,11 @@ func (self *Mediator) RateCdr(storedCdr *utils.StoredCdr, sendToStats bool) erro if err := self.rateCDR(cdr); err != nil { extraInfo = err.Error() } - if err := self.cdrDb.SetRatedCdr(cdr, extraInfo); err != nil { - Logger.Err(fmt.Sprintf(" Could not record cost for cgrid: <%s>, ERROR: <%s>, cost: %f, extraInfo: %s", - cdr.CgrId, err.Error(), cdr.Cost, extraInfo)) + if !self.cgrCfg.MediatorStoreDisable { + if err := self.cdrDb.SetRatedCdr(cdr, extraInfo); err != nil { + Logger.Err(fmt.Sprintf(" Could not record cost for cgrid: <%s>, ERROR: <%s>, cost: %f, extraInfo: %s", + cdr.CgrId, err.Error(), cdr.Cost, extraInfo)) + } } if sendToStats && self.stats != nil { // We send to stats only after saving to db since there are chances we cannot store and then no way to reproduce stats offline go func() {