babashka / pod-babashka-fswatcher

Babashka filewatcher pod.
BSD 3-Clause "New" or "Revised" License
22 stars 3 forks source link

Dedup by default #19

Closed fjsousa closed 1 year ago

fjsousa commented 1 year ago

Addresses https://github.com/babashka/pod-babashka-fswatcher/issues/18

fsnotify was creating many file notifications consecutively, which can be disruptive, for instance, if you have a build tool that gets triggered on file changes.

fsnotify has an example of deduping based on timers that I implemented here, replacing the debounce logic which was letting duplicates come through.

fjsousa commented 1 year ago

ready for review

borkdude commented 1 year ago

@lispyclouds Want to help review this PR? I see debounce was changed to dedup. Does this also mean that you will never see a duplicate event even after a long time?

lispyclouds commented 1 year ago

I'll try to have a look hopefully today. Will do some local tests.

lispyclouds commented 1 year ago

@fjsousa could you share the link for the fsnotify example that was used as reference here? The link in your comment is probably not what was intended?

fjsousa commented 1 year ago

@lispyclouds

I've updated the comment with the correct link for the fsnotify example: https://github.com/fsnotify/fsnotify/blob/main/cmd/fsnotify/dedup.go

lispyclouds commented 1 year ago

Sorry it took a while for me, too much tied up in work 😞 but looks good to me! @borkdude the implementation here should get rid of the dups. Its a bit convoluted as Go maps are not concurrent.