watcher

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MPL-2.0, MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// Path holds the absolute path to the file/directory.
	Path string

	// Op defines the file/directory operation.
	Op Op
}

Event instances are passed to Subscriber implementations on file/directory activity.

type Fsnotify

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

func (*Fsnotify) AddPath

func (w *Fsnotify) AddPath(name string) (err error)

func (*Fsnotify) AddSubscriber

func (w *Fsnotify) AddSubscriber(sub Subscriber) error

func (*Fsnotify) Close

func (w *Fsnotify) Close() (err error)

func (*Fsnotify) Debounce

func (w *Fsnotify) Debounce(d time.Duration)

func (*Fsnotify) RemovePath

func (w *Fsnotify) RemovePath(name string) (err error)

type Op

type Op uint8

Op is used for file/directory operation codes.

const (
	Create Op = 1 << iota
	Rename
	Remove
	Write
)

func (Op) String

func (o Op) String() string

type Subscriber

type Subscriber interface {
	Event(Event)
	Error(error)
}

Subscriber implementations receive Event and error values.

type Watcher

type Watcher interface {
	// AddSubscriber appends the list of subscribers that receive event/error details.
	AddSubscriber(Subscriber) error

	// AddPath appends the file/directory (non-recursive) to the watch list and
	// begins monitoring in a new goroutine.
	//
	// Absolute and relative paths are supported. However all paths are made absolute internally.
	AddPath(string) error

	// RemovePath stops the file/directory (non-recursive) from being watched.
	//
	// Absolute and relative paths are supported.
	RemovePath(string) error

	// Close ends all monitoring behavior and clears the watch/subscriber list.
	Close() error

	// Set the amount of time to wait for duplicate events (same Event.String output value)
	// to be received before broadcasting one Event value to subscribers.
	//
	// Implementations should not debounce events if this method is not called.
	Debounce(time.Duration)
}

Jump to

Keyboard shortcuts

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