fswatch

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadTimeout = errors.New("failed to read an event within the timeout")
	ErrStopTimeout = errors.New("recursive watcher did not shutdown within the timeout")
)

Functions

func DebounceOnGitOp

func DebounceOnGitOp(e Event) bool

func IsGeneratedFile

func IsGeneratedFile(e Event) bool

Types

type Event

type Event struct {
	fsnotify.Event

	// GitOp indicates if the event occurred while a git operation was in progress
	// This will be true when GitRoot/.git/index.lock exists
	GitOp bool
}

type Option

type Option func(*RecursiveWatcher) error

func WithDetectGitRoot

func WithDetectGitRoot() Option

func WithEventsChannel

func WithEventsChannel(events chan Event) Option

func WithGitRoot

func WithGitRoot(gitRoot string) Option

type RecursiveWatcher

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

func NewRecursiveWatcher

func NewRecursiveWatcher(ctx context.Context, dir string, opts ...Option) (rw *RecursiveWatcher, err error)

func (*RecursiveWatcher) AddDir

func (rw *RecursiveWatcher) AddDir(path string) error

func (*RecursiveWatcher) Errors

func (rw *RecursiveWatcher) Errors() <-chan error

func (*RecursiveWatcher) Events

func (rw *RecursiveWatcher) Events() <-chan Event

func (*RecursiveWatcher) ReadOne

func (rw *RecursiveWatcher) ReadOne(timeout time.Duration) (Event, error)

func (*RecursiveWatcher) Start

func (rw *RecursiveWatcher) Start()

Start starts the RecursiveWatcher by running the event loop in a separate goroutine. This method waits until the goroutine has started before returning. Call Stop to stop the watcher and wait for it to shut down.

func (*RecursiveWatcher) Stop

func (rw *RecursiveWatcher) Stop(timeout time.Duration) (err error)

Stop stops the RecursiveWatcher and waits for it to shut down. If the watcher does not shut down within the specified timeout, an error is returned.

Jump to

Keyboard shortcuts

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