mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-10 02:43:37 +02:00
preparing for v0.5
This commit is contained in:
25
src/watcher/file_watcher.go
Normal file
25
src/watcher/file_watcher.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package watcher
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
|
||||
E "github.com/yusing/go-proxy/error"
|
||||
)
|
||||
|
||||
type fileWatcher struct {
|
||||
filename string
|
||||
}
|
||||
|
||||
func NewFileWatcher(filename string) Watcher {
|
||||
if path.Base(filename) != filename {
|
||||
panic("filename must be a relative path")
|
||||
}
|
||||
return &fileWatcher{filename: filename}
|
||||
}
|
||||
|
||||
func (f *fileWatcher) Events(ctx context.Context) (<-chan Event, <-chan E.NestedError) {
|
||||
return fwHelper.Add(ctx, f)
|
||||
}
|
||||
|
||||
var fwHelper = newFileWatcherHelper()
|
||||
Reference in New Issue
Block a user