watcher

package
v0.0.0-...-970e190 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChmodEvent is emitted when a File attributes was changed.
	ChmodEvent = EventType(fsnotify.Chmod)

	// WriteEvent is emitted when a pathname was written to; this does *not* mean the write has finished.
	WriteEvent = EventType(fsnotify.Write)

	// CreateEvent is emitted when a path(dir or file) was created
	CreateEvent = EventType(fsnotify.Create)

	// RemoveEvent is emitted when a path was removed; any watches on it will be removed.
	RemoveEvent = EventType(fsnotify.Remove)

	// RenameEvent is emitted when a path was renamed to something else;
	// any watched on it will be removed.
	RenameEvent = EventType(fsnotify.Rename)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configs

type Configs struct {
	// Exts is the list of file extensions to watch for
	Exts []string

	// Paths is the list of directories and subdirectories we are watching
	Paths []string

	// Exclude is the list of directories to Exclude from the watch list
	Exclude []string

	// recursive set the Delay for event handlers execution
	Delay time.Duration

	// RootDir iis the current working directory
	RootDir string

	// Recursive enables watching on the subdirectories of the paths in the watch list
	Recursive bool

	// RootPaths is the list of parent directories to watch from the config
	RootPaths []string
}

func NewConfigs

func NewConfigs(config config.Config) *Configs

type Event

type Event struct {
	Path string
	Type EventType
}

func NewEvent

func NewEvent(t EventType, p string) *Event

type EventHandler

type EventHandler func(Event)

type EventType

type EventType uint32

func (EventType) String

func (e EventType) String() string

type Watcher

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

func New

func New(configs *Configs) (*Watcher, error)

func (*Watcher) Close

func (w *Watcher) Close() error

func (*Watcher) Listen

func (w *Watcher) Listen(onListen func(configs Configs))

func (*Watcher) OnError

func (w *Watcher) OnError(h func(error))

func (*Watcher) OnEvent

func (w *Watcher) OnEvent(eType EventType, handler EventHandler)

func (*Watcher) Watch

func (w *Watcher) Watch(paths ...string) error

Jump to

Keyboard shortcuts

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