ees: remove init from libcdre, rename to failedposts

This commit is contained in:
ionutboangiu
2025-10-24 18:08:47 +03:00
committed by Dan Christian Bogos
parent 295ddec792
commit 4c30ec4e4c
6 changed files with 8 additions and 11 deletions

View File

@@ -269,6 +269,7 @@ func TestV1ProcessEvent4(t *testing.T) {
cfg.EEsCfg().Exporters[0].Type = utils.MetaHTTPPost
cfg.EEsCfg().Exporters[0].ID = "SQLExporterFull"
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)
if err != nil {
t.Error(err)

View File

@@ -35,12 +35,8 @@ import (
var failedPostCache *ltcache.Cache
func init() {
failedPostCache = ltcache.NewCache(-1, 5*time.Second, false, false, []func(itmID string, value any){writeFailedPosts}) // configurable general
}
// SetFailedPostCacheTTL recreates the failed cache
func SetFailedPostCacheTTL(ttl time.Duration, static bool) {
// InitFailedPostCache initializes the failed posts cache.
func InitFailedPostCache(ttl time.Duration, static bool) {
failedPostCache = ltcache.NewCache(-1, ttl, static, false, []func(itmID string, value any){writeFailedPosts})
}

View File

@@ -30,7 +30,7 @@ import (
func TestSetFldPostCacheTTL(t *testing.T) {
var1 := failedPostCache
SetFailedPostCacheTTL(50*time.Millisecond, false)
InitFailedPostCache(50*time.Millisecond, false)
var2 := failedPostCache
if reflect.DeepEqual(var1, var2) {
t.Error("Expecting to be different")
@@ -38,7 +38,7 @@ func TestSetFldPostCacheTTL(t *testing.T) {
}
func TestAddFldPost(t *testing.T) {
SetFailedPostCacheTTL(5*time.Second, false)
InitFailedPostCache(5*time.Second, false)
AddFailedPost("", "path1", "format1", "1", &config.EventExporterOpts{
AMQP: &config.AMQPOpts{},
Els: &config.ElsOpts{},

View File

@@ -66,7 +66,7 @@ type TestContent struct {
}
func TestHttpJsonPoster(t *testing.T) {
SetFailedPostCacheTTL(time.Millisecond, false)
InitFailedPostCache(time.Millisecond, false)
content := &TestContent{Var1: "Val1", Var2: "Val2"}
jsn, _ := json.Marshal(content)
pstr, err := NewHTTPjsonMapEE(&config.EventExporterCfg{
@@ -123,7 +123,7 @@ func TestHttpJsonPoster(t *testing.T) {
}
func TestHttpBytesPoster(t *testing.T) {
SetFailedPostCacheTTL(time.Millisecond, false)
InitFailedPostCache(time.Millisecond, false)
content := []byte(`Test
Test2
`)