watcher

package
v0.0.0-...-dfce1b8 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 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 DirWatcher

type DirWatcher struct {
	Errors chan error
	Events chan Event
	// contains filtered or unexported fields
}

DirWatcher allows to watch directories. DirWatcher returns an error when trying to watch files.

func NewDirWatcher

func NewDirWatcher(logger *zap.SugaredLogger) (*DirWatcher, error)

func (*DirWatcher) Add

func (dw *DirWatcher) Add(dirpath string) error

func (*DirWatcher) Remove

func (dw *DirWatcher) Remove(dirpath string) error

type Event

type Event struct {
	Path      string `json:"path"`
	Name      string `json:"name"`
	Operation Op     `json:"operation"`
	// Timestamp is nanoseconds since epoch
	Timestamp int64 `json:"timestamp"`
	// Directory doesn't hold a valid value for the remove operation.
	// Because we can't stat a path that just got removed to find out
	// if it was a file or a dir that got removed.
	Directory bool `json:"isDir"`
}

type Op

type Op string
const (
	Create Op = "Create"
	Write  Op = "Write"
	Remove Op = "Remove"
	Rename Op = "Rename"
	Chmod  Op = "Chmod"
)

Jump to

Keyboard shortcuts

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