watcher

package
v3.0.0-rc9+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 6 Imported by: 60

Documentation

Overview

Package watcher provides a way of watching for filesystem events and notifying observers when they occur.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateEvent

type CreateEvent struct {
	Pathname string
}

CreateEvent signifies a file was created in a watched directory.

type DeleteEvent

type DeleteEvent struct {
	Pathname string
}

DeleteEvent signifies a watched file was deleted.

type Event

type Event interface {
}

Event is a generalisation of events sent from the watcher to its listeners.

type FakeWatcher

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

FakeWatcher implements an in-memory Watcher.

func NewFakeWatcher

func NewFakeWatcher() *FakeWatcher

NewFakeWatcher returns a fake Watcher for use in tests.

func (*FakeWatcher) Add

func (w *FakeWatcher) Add(name string) error

Add adds a watch to the FakeWatcher

func (*FakeWatcher) Close

func (w *FakeWatcher) Close() error

Close closes down the FakeWatcher

func (*FakeWatcher) Events

func (w *FakeWatcher) Events() <-chan Event

Events returns a new channel of messages.

func (*FakeWatcher) InjectCreate

func (w *FakeWatcher) InjectCreate(name string)

InjectCreate lets a test inject a fake creation event.

func (*FakeWatcher) InjectDelete

func (w *FakeWatcher) InjectDelete(name string)

InjectDelete lets a test inject a fake deletion event.

func (*FakeWatcher) InjectUpdate

func (w *FakeWatcher) InjectUpdate(name string)

InjectUpdate lets a test inject a fake update event.

func (*FakeWatcher) Remove

func (w *FakeWatcher) Remove(name string) error

Remove removes a watch from the FakeWatcher

type LogWatcher

type LogWatcher struct {
	*fsnotify.Watcher
	// contains filtered or unexported fields
}

LogWatcher implements a Watcher for watching real filesystems.

func NewLogWatcher

func NewLogWatcher() (*LogWatcher, error)

NewLogWatcher returns a new LogWatcher, or returns an error.

func (*LogWatcher) Close

func (w *LogWatcher) Close() (err error)

Close shuts down the LogWatcher. It is safe to call this from multiple clients because

func (*LogWatcher) Events

func (w *LogWatcher) Events() <-chan Event

Events returns a new readable channel of events from this watcher.

type UpdateEvent

type UpdateEvent struct {
	Pathname string
}

UpdateEvent signifies a watched file was modified.

type Watcher

type Watcher interface {
	Add(name string) error
	Close() error
	Remove(name string) error
	Events() <-chan Event
}

Watcher describes an interface for filesystem watching.

Jump to

Keyboard shortcuts

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