Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileWatcher ¶
type FileWatcher struct { sync.Mutex // the interval that we will check the existence of the file again // default = 5s, can be adjustable, especially for unittests CheckFileInterval time.Duration // contains filtered or unexported fields }
FileWatcher is a helper struct that helps us watching a file event if the file does't exist yet
func New ¶
func New( filePath string, onChangeHandler func(f *FileWatcher, event fsnotify.Event), onErrorHandler func(f *FileWatcher, err error) bool, ) (*FileWatcher, error)
Create new watcher for a file with some pre-defined handlers
func (*FileWatcher) FileExist ¶
func (f *FileWatcher) FileExist() bool
the watched file exists ot not?
func (*FileWatcher) InWatchedQueue ¶
func (f *FileWatcher) InWatchedQueue() bool
is the file in the watched queue?
func (*FileWatcher) SetFileExist ¶
func (f *FileWatcher) SetFileExist(value bool)
set the existence of the watched file
func (*FileWatcher) SetInWatchedQueue ¶
func (f *FileWatcher) SetInWatchedQueue(value bool)
update the status of the file in the watched queue
func (*FileWatcher) Watch ¶
func (f *FileWatcher) Watch(ctx context.Context)
Start watching the file Even when the file is deleted and re-created, the watcher can still put an eye on it until the context is done
Click to show internal directories.
Click to hide internal directories.