fs

package
v1.0.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// OpUnsupported stands for currently unsupported file operation type.
	OpUnsupported = Op(iota)
	// OpRemove is used when watched file was removed.
	OpRemove
	// OpCreate is used when watched file was created.
	OpCreate
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op int

Op is a separate type for watch file events.

type UsageInfo

type UsageInfo struct {
	MountPoint string
	Bytes      int64
	Inodes     int64
}

UsageInfo holds metrics on fs usage.

func Usage

func Usage(path string) (*UsageInfo, error)

Usage collects fs usage for specific location, often a directory.

type WatchEvent

type WatchEvent struct {
	Path string
	Op   Op
}

WatchEvent is a single event that happens during filesystem watch.

type Watcher

type Watcher struct {
	*fsnotify.Watcher
}

Watcher is a filesystem watcher that can be used to watch filesystem changes.

func NewWatcher

func NewWatcher(files ...string) (*Watcher, error)

NewWatcher creates new Watcher that will be watching passed files or directories that already exist. Currently only create and remove operations are supported. NOTE: when watching a single file no new event will be triggered after it's removal.

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context) <-chan WatchEvent

Watch starts filesystem watching, all occurred events will be sent to returned channel. Returned channel is unbuffered, so make sure to read from it. Watcher will be cancelled as soon as context is done.

Jump to

Keyboard shortcuts

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