Skip to content

FileWatcher is a simple utility to monitor files inside a directory with a TTL buffer

Notifications You must be signed in to change notification settings

0x0J/fileWatcher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

fileWatcher package is a utility to monitor new files in a directory. Its mainly used as an ingress monitor for file based transfers.

FileWatcher has a TTL which is used by a buffer to avoid reporting new files. Those files are stored in the buffered in TTL (seconds) When time has ran out, they will be reported again, it is up to the using system to remove / move files.

ExecutionTime is how often the directory should be monitored.

Recommended usage:

// Create a channel with string
filechannel := make(chan string)
// Create a file watcher
watcher := filewatcher.NewFileWatcher()
watcher.ChangeExecutionTime(1)
watcher.ChangeTTL(5)
go watcher.WatchDirectory(filechannel, "./fileWatcher/")

for {
	select {
	case newFile := <-filechannel:
		fmt.Println(newFile)
	}
}

About

FileWatcher is a simple utility to monitor files inside a directory with a TTL buffer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%