watcher

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IFace

type IFace interface {
	Init() error
	Watch()
	Register(func(bts []byte))
	UpdateBytes() error
	ReadFile() ([]byte, error)
}

IFace interface for the the file system watcher.

type Watcher

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

Watcher is a wrapper for `fsnotify` that provides the registration of a callback for WRITE events. It uses a 5 second polling fallback to periodically reload dcdr file changes, in the event that the watcher does not fire.

func New added in v0.2.2

func New(path string) (w *Watcher)

New initializes a Watcher and verifies that `path` exists.

func (*Watcher) Close added in v0.3.0

func (w *Watcher) Close()

func (*Watcher) Init

func (w *Watcher) Init() error

Init creates a new `fsnotify` watcher observing `path`.

func (*Watcher) ReadFile

func (w *Watcher) ReadFile() ([]byte, error)

ReadFile reads the contents of `path`.

func (*Watcher) Register

func (w *Watcher) Register(cb func(bts []byte))

Register assigns the WRITE event callback.

func (*Watcher) UpdateBytes added in v0.2.2

func (w *Watcher) UpdateBytes() error

UpdateBytes reads the contents of `path` and passes the bytes to `writeCallback`.

func (*Watcher) Watch

func (w *Watcher) Watch()

Jump to

Keyboard shortcuts

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