added StartDelay for ers processing

This commit is contained in:
gezimbll
2024-11-14 15:38:10 +01:00
committed by Dan Christian Bogos
parent 3a6d759bac
commit e48eb5df13
20 changed files with 252 additions and 5 deletions

View File

@@ -123,6 +123,16 @@ func (rdr *SQLEventReader) Serve() (err error) {
func (rdr *SQLEventReader) readLoop(db *gorm.DB, sqlDB io.Closer) {
defer sqlDB.Close()
if rdr.Config().StartDelay > 0 {
select {
case <-time.After(rdr.Config().StartDelay):
case <-rdr.rdrExit:
utils.Logger.Info(
fmt.Sprintf("<%s> stop monitoring sql DB <%s>",
utils.ERs, rdr.Config().SourcePath))
return
}
}
tm := time.NewTimer(0)
for {
rows, err := db.Table(rdr.tableName).Select(utils.Meta).Rows()