pkg: istio.io/pkg/filewatcher Index | Files

package filewatcher

import "istio.io/pkg/filewatcher"

Index

Package Files

fakefilewatcher.go filewatcher.go worker.go

func NewFakeWatcher Uses

func NewFakeWatcher(changedFunc func(path string, added bool)) (NewFileWatcherFunc, *FakeWatcher)

NewFakeWatcher returns a function which creates a new fake watcher for unit testing. This allows observe callers to inject events and errors per-watched path. changedFunc() provides a callback notification when a new watch is added or removed. Production code should use `NewWatcher()`.

type FakeWatcher Uses

type FakeWatcher struct {
    sync.Mutex
    // contains filtered or unexported fields
}

FakeWatcher provides a fake file watcher implementation for unit tests. Production code should use the `NewWatcher()`.

func (*FakeWatcher) Add Uses

func (w *FakeWatcher) Add(path string) error

Add is a fake implementation of the FileWatcher interface.

func (*FakeWatcher) Close Uses

func (w *FakeWatcher) Close() error

Close is a fake implementation of the FileWatcher interface.

func (*FakeWatcher) Errors Uses

func (w *FakeWatcher) Errors(path string) chan error

Errors is a fake implementation of the FileWatcher interface.

func (*FakeWatcher) Events Uses

func (w *FakeWatcher) Events(path string) chan fsnotify.Event

Events is a fake implementation of the FileWatcher interface.

func (*FakeWatcher) InjectError Uses

func (w *FakeWatcher) InjectError(path string, err error)

InjectError injects an error into the fake file watcher.

func (*FakeWatcher) InjectEvent Uses

func (w *FakeWatcher) InjectEvent(path string, event fsnotify.Event)

InjectEvent injects an event into the fake file watcher.

func (*FakeWatcher) Remove Uses

func (w *FakeWatcher) Remove(path string) error

Remove is a fake implementation of the FileWatcher interface.

type FileWatcher Uses

type FileWatcher interface {

    // Start watching a path. Calling Add multiple times on the same path panics.
    Add(path string) error

    // Stop watching a path. Removing a path that's not currently being watched panics.
    Remove(path string) error

    Close() error
    Events(path string) chan fsnotify.Event
    Errors(path string) chan error
}

FileWatcher is an interface that watches a set of files, delivering events to related channel.

func NewWatcher Uses

func NewWatcher() FileWatcher

NewWatcher return with a FileWatcher instance that implemented with fsnotify.

type NewFileWatcherFunc Uses

type NewFileWatcherFunc func() FileWatcher

NewFileWatcherFunc returns a function which creates a new file watcher. This may be used to provide test hooks for using the FakeWatcher implementation below.

Package filewatcher imports 10 packages (graph) and is imported by 13 packages. Updated 2019-09-21. Refresh now. Tools for package owners.