Update behaviour of file readers using inotify

Ensure that files already existing in the source path are processed
before the reader starts listening for filesystem change events.
This commit is contained in:
ionutboangiu
2024-09-23 19:01:05 +03:00
committed by Dan Christian Bogos
parent 65e8128303
commit 63c1358c3f
4 changed files with 20 additions and 0 deletions

View File

@@ -81,6 +81,11 @@ func (rdr *CSVFileER) Serve() (err error) {
case time.Duration(0): // 0 disables the automatic read, maybe done per API
return
case time.Duration(-1):
// Ensure that files already existing in the source path are processed
// before the reader starts listening for filesystem change events.
processReaderDir(rdr.sourceDir, utils.CSVSuffix, rdr.processFile)
return utils.WatchDir(rdr.sourceDir, rdr.processFile,
utils.ERs, rdr.rdrExit)
default:

View File

@@ -89,6 +89,11 @@ func (rdr *FWVFileER) Serve() (err error) {
case time.Duration(0): // 0 disables the automatic read, maybe done per API
return
case time.Duration(-1):
// Ensure that files already existing in the source path are processed
// before the reader starts listening for filesystem change events.
processReaderDir(rdr.sourceDir, utils.FWVSuffix, rdr.processFile)
return utils.WatchDir(rdr.sourceDir, rdr.processFile,
utils.ERs, rdr.rdrExit)
default:

View File

@@ -82,6 +82,11 @@ func (rdr *JSONFileER) Serve() (err error) {
case time.Duration(0): // 0 disables the automatic read, maybe done per API
return
case time.Duration(-1):
// Ensure that files already existing in the source path are processed
// before the reader starts listening for filesystem change events.
processReaderDir(rdr.sourceDir, utils.JSONSuffix, rdr.processFile)
return utils.WatchDir(rdr.sourceDir, rdr.processFile,
utils.ERs, rdr.rdrExit)
default:

View File

@@ -83,6 +83,11 @@ func (rdr *XMLFileER) Serve() (err error) {
case time.Duration(0): // 0 disables the automatic read, maybe done per API
return
case time.Duration(-1):
// Ensure that files already existing in the source path are processed
// before the reader starts listening for filesystem change events.
processReaderDir(rdr.sourceDir, utils.XMLSuffix, rdr.processFile)
return utils.WatchDir(rdr.sourceDir, rdr.processFile,
utils.ERs, rdr.rdrExit)
default: