filenotifywatcher

package
v0.0.0-...-ac56535 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func WithLogger(logger Logger) Option

WithLogger is an option for NewWatcher that specifies the logger to use.

func WithPath

func WithPath(path string) Option

WithPath is an option for NewWatcher that specifies the path to watch.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

func (*Watcher) Changes

func (w *Watcher) Changes() <-chan bool

Changes returns the changes for the given fileName.

func (*Watcher) Kill

func (w *Watcher) Kill()

Kill is part of the worker.Worker interface.

func (*Watcher) Wait

func (w *Watcher) Wait() error

Wait is part of the worker.Worker interface.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL