Added failover test with multiple events in a single file

This commit is contained in:
Trial97
2020-01-28 10:20:04 +02:00
committed by Dan Christian Bogos
parent 9285d5ba2e
commit e0b9dcb35d
6 changed files with 446 additions and 22 deletions

View File

@@ -20,14 +20,8 @@ package engine
import (
"net/url"
"os"
"path"
"strings"
"sync"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/guardian"
"github.com/cgrates/cgrates/utils"
)
const (
@@ -68,20 +62,6 @@ type Poster interface {
Close()
}
func writeToFile(fileDir, fileName string, content []byte) (err error) {
fallbackFilePath := path.Join(fileDir, fileName)
_, err = guardian.Guardian.Guard(func() (interface{}, error) {
fileOut, err := os.Create(fallbackFilePath)
if err != nil {
return nil, err
}
_, err = fileOut.Write(content)
fileOut.Close()
return nil, err
}, config.CgrConfig().GeneralCfg().LockingTimeout, utils.FileLockPrefix+fallbackFilePath)
return
}
func parseURL(dialURL string) (URL string, qID string, err error) {
u, err := url.Parse(dialURL)
if err != nil {