recwatch

package
v0.0.0-...-173ccf6 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package recwatch provides recursive file watching events via fsnotify.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigWatcher

type ConfigWatcher struct {
	Flags Flags
	// contains filtered or unexported fields
}

ConfigWatcher returns events on a channel anytime one of its files events.

func NewConfigWatcher

func NewConfigWatcher() *ConfigWatcher

NewConfigWatcher creates a new ConfigWatcher struct.

func (*ConfigWatcher) Add

func (obj *ConfigWatcher) Add(file ...string)

Add new file paths to watch for events on.

func (*ConfigWatcher) Close

func (obj *ConfigWatcher) Close()

Close shuts down the ConfigWatcher object. It closes the Events channel after all the currently pending events have been emptied.

func (*ConfigWatcher) ConfigWatch

func (obj *ConfigWatcher) ConfigWatch(file string) chan error

ConfigWatch writes on the channel every time an event is seen for the path.

func (*ConfigWatcher) Error

func (obj *ConfigWatcher) Error() <-chan error

Error returns a channel of errors that notifies us of permanent issues.

func (*ConfigWatcher) Events

func (obj *ConfigWatcher) Events() chan string

Events returns a channel to listen on for file events. It closes when it is emptied after the Close() method is called. You can test for closure with the f, more := <-obj.Events() pattern.

type Event

type Event struct {
	Error error
	Body  *fsnotify.Event
}

Event represents a watcher event. These can include errors.

type Flags

type Flags struct {
	Debug bool
}

Flags contains all the constant flags that recwatch needs.

type RecWatcher

type RecWatcher struct {
	Path    string // computed path
	Recurse bool   // should we watch recursively?
	Flags   Flags
	// contains filtered or unexported fields
}

RecWatcher is the struct for the recursive watcher. Run Init() on it.

func NewRecWatcher

func NewRecWatcher(path string, recurse bool) (*RecWatcher, error)

NewRecWatcher creates an initializes a new recursive watcher.

func (*RecWatcher) Close

func (obj *RecWatcher) Close() error

Close shuts down the watcher.

func (*RecWatcher) Events

func (obj *RecWatcher) Events() chan Event

Events returns a channel of events. These include events for errors.

func (*RecWatcher) Init

func (obj *RecWatcher) Init() error

Init starts the recursive file watcher.

func (*RecWatcher) Watch

func (obj *RecWatcher) Watch() error

Watch is the primary listener for this resource and it outputs events.

Jump to

Keyboard shortcuts

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