watcher

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WatchEvent

type WatchEvent struct {
	Name string `yaml:"name"` // Name is the name of the origin watcher set
	Path string // Path is the path to the modified file or directory
	Type string // Type holds the kind of event that happened (create, write, remove)
}

type Watcher

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

Watcher is a code monitor for multiple projects

func NewWatcher

func NewWatcher(pub *pubsub.ElemPublisher) *Watcher

NewWatcher creates a watcher instance.

func (*Watcher) Add

func (w *Watcher) Add(ws *WatcherSet) error

Add adds a set of files to a watcher.

func (*Watcher) Dispose

func (w *Watcher) Dispose()

Dispose stops the go-routine of this watcher and releases all resources used by this watcher

func (*Watcher) Remove

func (w *Watcher) Remove(name string)

Remove the watch set from this watcher.

func (*Watcher) Start

func (w *Watcher) Start() chan error

Start starts a new go-routine that monitors the watcher set and publishes an event when there's code change. Start returns an error channel. Whenever an error occurs within Start, that error will be fed into the error channel. Start and its goroutine will then return, leaving the error channel with only the last error that occurred If there is no error, checking the channel will return a nil value Errors will occur under the following circumstances: there is already a Start goroutine running fsnotify could not create a fileWatcher filepath could not perform a walk of the target project a directory cannot be added to the filewatcher filewatcher failed in reported/receiving an event goroutine failed to get info about the file/directory In the case of an error, the returned channel will close

type WatcherSet

type WatcherSet struct {
	Name  string   `yaml:"name" json:"name"`   // Name is the name of this set
	Watch []string `yaml:"watch" json:"watch"` // A list of glob patterns to watch
}

WatcherSet is a set of directories or files to watch.

Jump to

Keyboard shortcuts

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