watcherx

package
v0.0.153 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSchemeUnknown is just for checking with errors.Is()
	ErrSchemeUnknown     = &errSchemeUnknown{}
	ErrWatcherNotRunning = fmt.Errorf("watcher is not running")
)

Functions

This section is empty.

Types

type ChangeEvent

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

func (*ChangeEvent) MarshalJSON

func (e *ChangeEvent) MarshalJSON() ([]byte, error)

func (*ChangeEvent) Reader

func (e *ChangeEvent) Reader() io.Reader

func (ChangeEvent) Source

func (e ChangeEvent) Source() string

func (*ChangeEvent) String

func (e *ChangeEvent) String() string

type ErrorEvent

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

func (*ErrorEvent) MarshalJSON

func (e *ErrorEvent) MarshalJSON() ([]byte, error)

func (*ErrorEvent) Reader

func (e *ErrorEvent) Reader() io.Reader

func (ErrorEvent) Source

func (e ErrorEvent) Source() string

func (*ErrorEvent) String

func (e *ErrorEvent) String() string

type Event

type Event interface {
	// MarshalJSON is required to work multiple times
	json.Marshaler

	Reader() io.Reader
	Source() string
	String() string
	// contains filtered or unexported methods
}

type EventChannel

type EventChannel chan Event

type RemoveEvent

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

func (*RemoveEvent) MarshalJSON

func (e *RemoveEvent) MarshalJSON() ([]byte, error)

func (*RemoveEvent) Reader

func (e *RemoveEvent) Reader() io.Reader

func (RemoveEvent) Source

func (e RemoveEvent) Source() string

func (*RemoveEvent) String

func (e *RemoveEvent) String() string

type Watcher

type Watcher interface {
	// DispatchNow fires the watcher and causes an event.
	//
	// WARNING: The returned channel must be read or no further events will
	// be propagated due to a deadlock.
	DispatchNow() (<-chan int, error)
}

func Watch

func Watch(ctx context.Context, u *url.URL, c EventChannel) (Watcher, error)

func WatchFile

func WatchFile(ctx context.Context, file string, c EventChannel) (Watcher, error)

WatchFile spawns a background goroutine to watch file, reporting any changes to c. When initially starting to watch the file fails, c is closed. Watching stops when ctx is canceled, at which point c is also closed.

Jump to

Keyboard shortcuts

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