watcher

package
v0.0.0-...-db2b026 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStop = errors.New("stop watching")

ErrStop informs the watcher to stop.

ErrStop is not an error, it's part of the control flow.

Functions

This section is empty.

Types

type Event

type Event struct {
	Op   Op
	Path string
}

Event is used to track file events

func (Event) String

func (e Event) String() string

type Op

type Op byte

Op is the type of file event that occurred

const (
	OpCreate Op = 'C'
	OpUpdate Op = 'U'
	OpDelete Op = 'D'
)

type Watcher

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

func NewWatcher

func NewWatcher(logger *zap.Logger) (*Watcher, error)

NewWatcher creates a new watcher

func (*Watcher) Wait

func (w *Watcher) Wait() error

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context, filePath string, fn func(events []Event) error) error

Watch watches a file for changes and triggers the provided function. The watcher stops when the context is canceled or an error is returned from the provided function.

Jump to

Keyboard shortcuts

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