Skip to content

Implement filesystem watcher input#688

Open
henrikschristensen wants to merge 4 commits intowarpstreamlabs:mainfrom
henrikschristensen:implement-filesystem-watcher-input
Open

Implement filesystem watcher input#688
henrikschristensen wants to merge 4 commits intowarpstreamlabs:mainfrom
henrikschristensen:implement-filesystem-watcher-input

Conversation

@henrikschristensen
Copy link
Copy Markdown

No description provided.

@henrikschristensen
Copy link
Copy Markdown
Author

resolves #649

@henrikschristensen henrikschristensen force-pushed the implement-filesystem-watcher-input branch 2 times, most recently from 688b0aa to 9ec374e Compare February 10, 2026 08:17
@henrikschristensen henrikschristensen force-pushed the implement-filesystem-watcher-input branch from 9ec374e to 257d39c Compare February 10, 2026 13:06
@henrikschristensen henrikschristensen force-pushed the implement-filesystem-watcher-input branch from 257d39c to b15c0e0 Compare February 12, 2026 18:02
@henrikschristensen henrikschristensen force-pushed the implement-filesystem-watcher-input branch 2 times, most recently from 0bc4c0b to 0b22a5c Compare February 23, 2026 09:23
@henrikschristensen henrikschristensen force-pushed the implement-filesystem-watcher-input branch from 0b22a5c to ce4d9d6 Compare February 23, 2026 16:12
}

func TestFSEventWatchNewSubdirsDeleteRecreate(t *testing.T) {
dir := t.TempDir()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a chance we can use the testing/fstest instead of actually creating files/dirs on the OS?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think that is possible unless we write a mock for fsnotify too that can produce filesystem events when changes are made to the MapFS in testing/fstest.
I have not been able to find any examples of doing that.
I am aware of the dilemma that the tests rely on the actual OS that it is executed on, but abstracting that part out into some kind of mock would be a lot of work i fear.
I assume fsnotify itself is tested cross platform.

Added fsevent input.
Can watch one or more folders for filesystem changes.
Emits messages with metadata describing the event.
@henrikschristensen henrikschristensen force-pushed the implement-filesystem-watcher-input branch from ce4d9d6 to 75ce1a6 Compare March 7, 2026 12:43
@henrikschristensen
Copy link
Copy Markdown
Author

@gregfurman

It is a known problem that fsnotify produces a lot of redundant events when f.ex. a file is saved to a dir. Then it will typical produce a CREATE event followed by several WRITE events depending on file size and maybe a CHMOD event. This makes it hard to detect when a file done being written to the disk and as a result u risk reading parts of the file or empty content.
The suggested solution from the fsnotify project is a simple deduplication/debouncing like this example https://github.com/fsnotify/fsnotify/blob/main/cmd/fsnotify/dedup.go.

I have tried to do something similar with existing bento components but I think it makes the resulting yaml very complicated and error prone.
So I think the best approach for this input is to implement something like the suggested dedup code.
An alternative could be to refactor the code into using this project https://github.com/sgtdi/fswatcher witch has buildin support for dedup and batching of events. But it is a single developer project and maybe not a good option for Bento.

Any thoughts on this?

@jem-davies
Copy link
Copy Markdown
Collaborator

#181

@jem-davies
Copy link
Copy Markdown
Collaborator

Fixes #232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants