From e3f9eb90158d8523ebd87d4e44ff0476c419bc36 Mon Sep 17 00:00:00 2001 From: Ildar Nurislamov Date: Tue, 5 Mar 2024 12:04:08 +0400 Subject: [PATCH] events log: log to CH only when CH is configured --- bulkerapp/app/app.go | 15 ++++----------- ingest/app.go | 14 +++----------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/bulkerapp/app/app.go b/bulkerapp/app/app.go index 257cbea..a0f9b43 100644 --- a/bulkerapp/app/app.go +++ b/bulkerapp/app/app.go @@ -59,24 +59,17 @@ func (a *Context) InitContext(settings *appbase.AppSettings) error { a.cron = NewCron(a.config) a.eventsLogService = &eventslog.DummyEventsLogService{} - elServices := []eventslog.EventsLogService{} + if a.config.ClickhouseHost != "" { - chEventsLogService, err := eventslog.NewClickhouseEventsLog(a.config.EventsLogConfig) + a.eventsLogService, err = eventslog.NewClickhouseEventsLog(a.config.EventsLogConfig) if err != nil { return err } - elServices = append(elServices, chEventsLogService) - } - eventsLogRedisUrl := utils.NvlString(a.config.EventsLogRedisURL, a.config.RedisURL) - if eventsLogRedisUrl != "" { - redisEventsLogService, err := eventslog.NewRedisEventsLog(eventsLogRedisUrl, a.config.RedisTLSCA, a.config.EventsLogMaxSize) + } else if eventsLogRedisUrl := utils.NvlString(a.config.EventsLogRedisURL, a.config.RedisURL); eventsLogRedisUrl != "" { + a.eventsLogService, err = eventslog.NewRedisEventsLog(eventsLogRedisUrl, a.config.RedisTLSCA, a.config.EventsLogMaxSize) if err != nil { return err } - elServices = append(elServices, redisEventsLogService) - } - if len(elServices) > 0 { - a.eventsLogService = &eventslog.MultiEventsLogService{Services: elServices} } a.fastStore, err = NewFastStore(a.config) diff --git a/ingest/app.go b/ingest/app.go index 65faa42..a85ab65 100644 --- a/ingest/app.go +++ b/ingest/app.go @@ -35,24 +35,16 @@ func (a *Context) InitContext(settings *appbase.AppSettings) error { a.repository = NewStreamsRepository(a.config.RepositoryURL, a.config.RepositoryAuthToken, a.config.RepositoryRefreshPeriodSec, a.config.CacheDir) a.scriptRepository = NewScriptRepository(a.config.ScriptOrigin, a.config.CacheDir) a.eventsLogService = &eventslog.DummyEventsLogService{} - elServices := []eventslog.EventsLogService{} if a.config.ClickhouseHost != "" { - chEventsLogService, err := eventslog.NewClickhouseEventsLog(a.config.EventsLogConfig) + a.eventsLogService, err = eventslog.NewClickhouseEventsLog(a.config.EventsLogConfig) if err != nil { return err } - elServices = append(elServices, chEventsLogService) - } - eventsLogRedisUrl := a.config.RedisURL - if eventsLogRedisUrl != "" { - redisEventsLogService, err := eventslog.NewRedisEventsLog(eventsLogRedisUrl, a.config.RedisTLSCA, a.config.EventsLogMaxSize) + } else if a.config.RedisURL != "" { + a.eventsLogService, err = eventslog.NewRedisEventsLog(a.config.RedisURL, a.config.RedisTLSCA, a.config.EventsLogMaxSize) if err != nil { return err } - elServices = append(elServices, redisEventsLogService) - } - if len(elServices) > 0 { - a.eventsLogService = &eventslog.MultiEventsLogService{Services: elServices} } a.kafkaConfig = a.config.GetKafkaConfig() //batch producer uses higher linger.ms and doesn't suit for sync delivery used by stream consumer when retrying messages