mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
ees: remove init from libcdre, rename to failedposts
This commit is contained in:
committed by
Dan Christian Bogos
parent
295ddec792
commit
4c30ec4e4c
@@ -269,6 +269,7 @@ func TestV1ProcessEvent4(t *testing.T) {
|
|||||||
cfg.EEsCfg().Exporters[0].Type = utils.MetaHTTPPost
|
cfg.EEsCfg().Exporters[0].Type = utils.MetaHTTPPost
|
||||||
cfg.EEsCfg().Exporters[0].ID = "SQLExporterFull"
|
cfg.EEsCfg().Exporters[0].ID = "SQLExporterFull"
|
||||||
cfg.EEsCfg().Exporters[0].Synchronous = true
|
cfg.EEsCfg().Exporters[0].Synchronous = true
|
||||||
|
InitFailedPostCache(cfg.EEsCfg().FailedPosts.TTL, cfg.EEsCfg().FailedPosts.StaticTTL)
|
||||||
newIDb, err := engine.NewInternalDB(nil, nil, true, nil, cfg.DataDbCfg().Items)
|
newIDb, err := engine.NewInternalDB(nil, nil, true, nil, cfg.DataDbCfg().Items)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|||||||
@@ -35,12 +35,8 @@ import (
|
|||||||
|
|
||||||
var failedPostCache *ltcache.Cache
|
var failedPostCache *ltcache.Cache
|
||||||
|
|
||||||
func init() {
|
// InitFailedPostCache initializes the failed posts cache.
|
||||||
failedPostCache = ltcache.NewCache(-1, 5*time.Second, false, false, []func(itmID string, value any){writeFailedPosts}) // configurable general
|
func InitFailedPostCache(ttl time.Duration, static bool) {
|
||||||
}
|
|
||||||
|
|
||||||
// SetFailedPostCacheTTL recreates the failed cache
|
|
||||||
func SetFailedPostCacheTTL(ttl time.Duration, static bool) {
|
|
||||||
failedPostCache = ltcache.NewCache(-1, ttl, static, false, []func(itmID string, value any){writeFailedPosts})
|
failedPostCache = ltcache.NewCache(-1, ttl, static, false, []func(itmID string, value any){writeFailedPosts})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
|
|
||||||
func TestSetFldPostCacheTTL(t *testing.T) {
|
func TestSetFldPostCacheTTL(t *testing.T) {
|
||||||
var1 := failedPostCache
|
var1 := failedPostCache
|
||||||
SetFailedPostCacheTTL(50*time.Millisecond, false)
|
InitFailedPostCache(50*time.Millisecond, false)
|
||||||
var2 := failedPostCache
|
var2 := failedPostCache
|
||||||
if reflect.DeepEqual(var1, var2) {
|
if reflect.DeepEqual(var1, var2) {
|
||||||
t.Error("Expecting to be different")
|
t.Error("Expecting to be different")
|
||||||
@@ -38,7 +38,7 @@ func TestSetFldPostCacheTTL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAddFldPost(t *testing.T) {
|
func TestAddFldPost(t *testing.T) {
|
||||||
SetFailedPostCacheTTL(5*time.Second, false)
|
InitFailedPostCache(5*time.Second, false)
|
||||||
AddFailedPost("", "path1", "format1", "1", &config.EventExporterOpts{
|
AddFailedPost("", "path1", "format1", "1", &config.EventExporterOpts{
|
||||||
AMQP: &config.AMQPOpts{},
|
AMQP: &config.AMQPOpts{},
|
||||||
Els: &config.ElsOpts{},
|
Els: &config.ElsOpts{},
|
||||||
@@ -66,7 +66,7 @@ type TestContent struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpJsonPoster(t *testing.T) {
|
func TestHttpJsonPoster(t *testing.T) {
|
||||||
SetFailedPostCacheTTL(time.Millisecond, false)
|
InitFailedPostCache(time.Millisecond, false)
|
||||||
content := &TestContent{Var1: "Val1", Var2: "Val2"}
|
content := &TestContent{Var1: "Val1", Var2: "Val2"}
|
||||||
jsn, _ := json.Marshal(content)
|
jsn, _ := json.Marshal(content)
|
||||||
pstr, err := NewHTTPjsonMapEE(&config.EventExporterCfg{
|
pstr, err := NewHTTPjsonMapEE(&config.EventExporterCfg{
|
||||||
@@ -123,7 +123,7 @@ func TestHttpJsonPoster(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpBytesPoster(t *testing.T) {
|
func TestHttpBytesPoster(t *testing.T) {
|
||||||
SetFailedPostCacheTTL(time.Millisecond, false)
|
InitFailedPostCache(time.Millisecond, false)
|
||||||
content := []byte(`Test
|
content := []byte(`Test
|
||||||
Test2
|
Test2
|
||||||
`)
|
`)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ type GlobalVarS struct {
|
|||||||
// Start should handle the sercive start
|
// Start should handle the sercive start
|
||||||
func (gv *GlobalVarS) Start() (err error) {
|
func (gv *GlobalVarS) Start() (err error) {
|
||||||
engine.SetRoundingDecimals(gv.cfg.GeneralCfg().RoundingDecimals)
|
engine.SetRoundingDecimals(gv.cfg.GeneralCfg().RoundingDecimals)
|
||||||
ees.SetFailedPostCacheTTL(gv.cfg.EEsCfg().FailedPosts.TTL, gv.cfg.EEsCfg().FailedPosts.StaticTTL)
|
ees.InitFailedPostCache(gv.cfg.EEsCfg().FailedPosts.TTL, gv.cfg.EEsCfg().FailedPosts.StaticTTL)
|
||||||
engine.SetHTTPPstrTransport(gv.cfg.HTTPCfg().ClientOpts)
|
engine.SetHTTPPstrTransport(gv.cfg.HTTPCfg().ClientOpts)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user