open-feature / flagd

A feature flag daemon with a Unix philosophy
https://openfeature.dev
Apache License 2.0
510 stars 61 forks source link

[FEATURE] filepath sync to poll version, in addition to using fsnotify #1344

Closed toddbaert closed 1 month ago

toddbaert commented 3 months ago

Requirements

Until now, we've been using fsnotify for watching files for change. This works well in K8s and most "prod" situations.

Unfortunately, due to the complexities and inconsistencies across OSes and editors, this simply doesn't work well in many developer cases, and even some prod cases (OSes and editors all send different combinations of events, some create temp files and move them, some use symlinks, etc, etc).

It's unreasonable to support all these different situations. I propose we add an additional mode or version of the filepath Sync to start a goroutine which uses os.Stat() to get the fs.FileInfo, noting the current time (time) and then we check fileInfo.ModTime().After(time) every n seconds and fire a sync event with new contents if we see it's changed. I think by default, n should be 1000ms, but it should be configurable. We could use some kind of startup param to select this mode and the poll internal.

cc @Kavindu-Dodan