aboutsummaryrefslogtreecommitdiffstats
path: root/worker/types
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2023-03-02 16:46:00 -0600
committerRobin Jarry <robin@jarry.cc>2023-03-07 16:37:02 +0100
commita0935a3de0cec483a605df5017307f50a186f5cb (patch)
tree4caff49e5f44a9e9943fa402b2f89d8f242196b4 /worker/types
parent182424d279532635cbae6b1a1817f61db64ee37f (diff)
downloadaerc-a0935a3de0cec483a605df5017307f50a186f5cb.tar.gz
worker/lib: implement an fswatcher interface
Implement an FSWatcher interface. The interface is used to abstract away file system watchers, which have implementation specific backends. The initial interface has one implementation: inotify for linux. Subsequent commits will add a macOS watcher. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/types')
-rw-r--r--worker/types/watcher.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/worker/types/watcher.go b/worker/types/watcher.go
new file mode 100644
index 00000000..b06d12d3
--- /dev/null
+++ b/worker/types/watcher.go
@@ -0,0 +1,24 @@
+package types
+
+// FSWatcher is a file system watcher
+type FSWatcher interface {
+ Configure(string) error
+ Events() chan *FSEvent
+ // Adds a directory or file to the watcher
+ Add(string) error
+ // Removes a directory or file from the watcher
+ Remove(string) error
+}
+
+type FSOperation int
+
+const (
+ FSCreate FSOperation = iota
+ FSRemove
+ FSRename
+)
+
+type FSEvent struct {
+ Operation FSOperation
+ Path string
+}