watcher

package
v0.0.0-...-2841839 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 6 Imported by: 0

README

watcher

import "github.com/cognusion/go-jar/watcher"

Overview

Package watcher is used to keep an eye on file system events, and trigger actions when those events are of interest.

Index

Package files

watcher.go

Variables

var (
    // DebugOut is a log.Logger for debug messages
    DebugOut = log.New(io.Discard, "[DEBUG] ", 0)
    // ErrorOut is a log.Logger for error messages
    ErrorOut = log.New(io.Discard, "", 0)
)

type WatchHandlerFunc

type WatchHandlerFunc func(fsnotify.Event)

WatchHandlerFunc takes an fsnotify.Event to add on. A WatchHandlerFunc can assume it will not be called more than once while running

type Watcher

type Watcher struct {
    // Close should be called when the Watcher is no longer of use. It is safe to call multiple times.
    Close func()
    // contains filtered or unexported fields
}

Watcher is an implementation of fsnotify.Watcher with some rails and opinions.

func NewWatcher
func NewWatcher() (*Watcher, error)

NewWatcher returns a Watcher or an error if a problem occurred creating it (very rare)

func NewWatcherWithErrorChan
func NewWatcherWithErrorChan(errorChan chan error) (*Watcher, error)

NewWatcherWithErrorChan returns a Watcher or an error if a problem occurred creating it (very rare). The supplied chan will receive non-nil errors if they occur

func (*Watcher) Add
func (w *Watcher) Add(file string, wf WatchHandlerFunc) error

Add takes a filename, and a WatchHandlerFunc to call if the file changes

func (*Watcher) Delete
func (w *Watcher) Delete(file string) error

Delete takes a filename, and removes it from being watched


Generated by godoc2md

Documentation

Overview

Package watcher is used to keep an eye on file system events, and trigger actions when those events are of interest.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DebugOut is a log.Logger for debug messages
	DebugOut = log.New(io.Discard, "[DEBUG] ", 0)
	// ErrorOut is a log.Logger for error messages
	ErrorOut = log.New(io.Discard, "", 0)
)

Functions

This section is empty.

Types

type WatchHandlerFunc

type WatchHandlerFunc func(fsnotify.Event)

WatchHandlerFunc takes an fsnotify.Event to add on. A WatchHandlerFunc can assume it will not be called more than once while running

type Watcher

type Watcher struct {
	// Close should be called when the Watcher is no longer of use. It is safe to call multiple times.
	Close func()
	// contains filtered or unexported fields
}

Watcher is an implementation of fsnotify.Watcher with some rails and opinions.

func NewWatcher

func NewWatcher() (*Watcher, error)

NewWatcher returns a Watcher or an error if a problem occurred creating it (very rare)

func NewWatcherWithErrorChan

func NewWatcherWithErrorChan(errorChan chan error) (*Watcher, error)

NewWatcherWithErrorChan returns a Watcher or an error if a problem occurred creating it (very rare). The supplied chan will receive non-nil errors if they occur

func (*Watcher) Add

func (w *Watcher) Add(file string, wf WatchHandlerFunc) error

Add takes a filename, and a WatchHandlerFunc to call if the file changes

func (*Watcher) Delete

func (w *Watcher) Delete(file string) error

Delete takes a filename, and removes it from being watched

Jump to

Keyboard shortcuts

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