mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
StoreDisable implementation for both CDRS and Mediator
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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("<Mediator> 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("<Mediator> 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() {
|
||||
|
||||
Reference in New Issue
Block a user