watch

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is a struct which allows to use fluent API to create underlying instance of Watch.

func CreateWatch

func CreateWatch(intervalMs int64) *Builder

CreateWatch creates instance of Builder providing fluent functions to customize watch

interval defines how frequently (in ms) file change events should be processed.

func (*Builder) Excluding

func (wb *Builder) Excluding(exclusions ...string) *Builder

Excluding allows to define exclusion patterns (as glob expressions).

func (*Builder) OnPaths

func (wb *Builder) OnPaths(paths ...string) (watch *Watch, err error)

OnPaths defines paths to be watched. If path is a directory it will recursively watch all files and subdirectories. If path is a file only this path is watched.

func (*Builder) WithHandlers

func (wb *Builder) WithHandlers(handlers ...Handler) *Builder

WithHandlers allows to register instances of Handler which will react on file change events.

type Handler

type Handler func(events []fsnotify.Event) error

Handler allows to define how to react on file changes event.

type Watch

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

Watch represents single file system watch and delegates change events to defined handler.

func (*Watch) Close

func (w *Watch) Close()

Close attempts to close underlying fsnotify.Watcher. In case of failure it logs the error.

func (*Watch) Excluded

func (w *Watch) Excluded(path string) bool

Excluded checks whether a path is excluded from watch by first inspecting .gitignores and user-defined exclusions.

func (*Watch) Start

func (w *Watch) Start()

Start observes on file change events and dispatches them to defined handler in batches every given interval.

Jump to

Keyboard shortcuts

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