Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewINotifyWatcher = newWatcher
NewInotifyWatcher returns a new INotifyWatcher.
Functions ¶
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns a dependency manifold that runs the filenotifywatcher worker, using the resource names defined in the supplied config.
Types ¶
type FileNotifyWatcher ¶
type FileNotifyWatcher interface { // Changes returns a channel for the given file name that will contain // if a file was created or deleted. // TODO (stickupkid): We could further advance this to return a channel // of ints that represents the number of changes we want to advance per // step. Changes(fileName string) (<-chan bool, error) }
FileNotifyWatcher represents a way to watch for changes in a namespace folder directory.
type FileWatcher ¶
type FileWatcher interface { worker.Worker // Changes returns a channel that will receive a value whenever the // watched file changes. Changes() <-chan bool }
FileWatcher is an interface that allows a worker to watch a file for changes.
func NewWatcher ¶
func NewWatcher(fileName string, opts ...Option) (FileWatcher, error)
type INotifyWatcher ¶
type INotifyWatcher interface { // Watch adds the given file or directory (non-recursively) to the watch. Watch(path string) error // Events returns the next event. Events() <-chan *inotify.Event // Errors returns the next error. Errors() <-chan error // Close removes all watches and closes the events channel. Close() error }
INotifyWatcher is an interface that allows a worker to watch a file for changes using inotify.
type Logger ¶
type Logger interface { Errorf(message string, args ...interface{}) Warningf(message string, args ...interface{}) Infof(message string, args ...interface{}) Debugf(message string, args ...interface{}) Tracef(message string, args ...interface{}) IsTraceEnabled() bool }
Logger represents the logging methods called.
type ManifoldConfig ¶
type ManifoldConfig struct { Clock clock.Clock Logger Logger NewWatcher WatcherFn NewINotifyWatcher func() (INotifyWatcher, error) }
ManifoldConfig defines the names of the manifolds on which a Manifold will depend.
func (ManifoldConfig) Validate ¶
func (cfg ManifoldConfig) Validate() error
type Option ¶
type Option func(*option)
func WithINotifyWatcherFn ¶
func WithINotifyWatcherFn(watcherFn func() (INotifyWatcher, error)) Option
WithINotifyWatcherFn is an option for NewWatcher that specifies the inotify watcher to use.
func WithLogger ¶
WithLogger is an option for NewWatcher that specifies the logger to use.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
type WatcherFn ¶
type WatcherFn = func(string, ...Option) (FileWatcher, error)
WatcherFn is a function that returns a new Watcher.
type WorkerConfig ¶
type WorkerConfig struct { Clock clock.Clock Logger Logger NewWatcher WatcherFn NewINotifyWatcher func() (INotifyWatcher, error) }
WorkerConfig encapsulates the configuration options for the changestream worker.
func (*WorkerConfig) Validate ¶
func (c *WorkerConfig) Validate() error
Validate ensures that the config values are valid.