watcher: handles stats resetting
This commit is contained in:
parent
3a10017590
commit
2f54f72499
@ -15,7 +15,7 @@ type WatchRunner interface {
|
|||||||
|
|
||||||
// If the browser needs the watcher to be reset for each new event
|
// If the browser needs the watcher to be reset for each new event
|
||||||
type ResetWatcher interface {
|
type ResetWatcher interface {
|
||||||
ResetWatcher() // resets a new watcher
|
ResetWatcher() error // resets a new watcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required interface to be implemented by browsers that want to use the
|
// Required interface to be implemented by browsers that want to use the
|
||||||
@ -28,6 +28,11 @@ type Runner interface {
|
|||||||
Run()
|
Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// interface for modules that keep stats
|
||||||
|
type Stats interface {
|
||||||
|
ResetStats()
|
||||||
|
}
|
||||||
|
|
||||||
// Wrapper around fsnotify watcher
|
// Wrapper around fsnotify watcher
|
||||||
type WatchDescriptor struct {
|
type WatchDescriptor struct {
|
||||||
ID string
|
ID string
|
||||||
@ -148,10 +153,14 @@ func WatcherThread(w WatchRunner) {
|
|||||||
ch <- event
|
ch <- event
|
||||||
} else {
|
} else {
|
||||||
w.Run()
|
w.Run()
|
||||||
|
if stats, ok := w.(Stats); ok {
|
||||||
|
stats.ResetStats()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.Warningf("event: %v | eventName: %v", event.Op, event.Name)
|
//log.Warningf("event: %v | eventName: %v", event.Op, event.Name)
|
||||||
|
|
||||||
|
//TODO!: remove condition and use interface instead
|
||||||
if watched.ResetWatch {
|
if watched.ResetWatch {
|
||||||
log.Debugf("resetting watchers")
|
log.Debugf("resetting watchers")
|
||||||
if r, ok := w.(ResetWatcher); ok {
|
if r, ok := w.(ResetWatcher); ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user