watcher

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFolderPathNotFound = errors.New("could not find a folder path for watcher")
)

Functions

This section is empty.

Types

type EventHandler

type EventHandler interface {
	OnCreate(ctx context.Context, path string, fileInfo os.FileInfo)
	OnRemove(ctx context.Context, path string, fileInfo os.FileInfo)
	OnWrite(ctx context.Context, path string, fileInfo os.FileInfo)
	OnRename(ctx context.Context, path string, fileInfo os.FileInfo, oldPath string)
	OnMove(ctx context.Context, path string, fileInfo os.FileInfo, oldPath string)
}

EventHandler

type FolderWatcher

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

func New

func New(configs ...Option) (*FolderWatcher, error)

New creates an new instance of folder watcher It listens to the path specified in the config space/folderPath

func (*FolderWatcher) Close

func (fw *FolderWatcher) Close()

Close will stop the watching operation and unblock watch calls

func (*FolderWatcher) RegisterHandler

func (fw *FolderWatcher) RegisterHandler(handler EventHandler)

func (*FolderWatcher) Watch

func (fw *FolderWatcher) Watch(ctx context.Context) error

Watch will start listening of changes on the FolderWatcher path and trigger the handler with any update events This is a block operation

type Option

type Option func(option *watcherOptions)

Option configuration for the FileWatcher Use exported Option factory functions

func WithPaths

func WithPaths(path ...string) Option

WithPaths configures the list of paths the file watcher would be watching recursively. For best results do not include two paths withing the same directory

Jump to

Keyboard shortcuts

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