Documentation ¶
Overview ¶
Package fs implements watching files for changes.
Example ¶
package main import ( "fmt" "go.thethings.network/lorawan-stack/v3/pkg/events" "go.thethings.network/lorawan-stack/v3/pkg/events/fs" ) func main() { fs.Watch("config.yml", events.HandlerFunc(func(evt events.Event) { if evt.Name() != "fs.write" { return } fmt.Println("Detected a configuration update") })) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Watcher ¶
type Watcher interface { // Watch a file for changes, the handler may be nil. Watch(name string, handler events.Handler) error Close() error }
Watcher interface for watching the filesystem for changes.
var DefaultWatcher Watcher
DefaultWatcher is the default filesystem Watcher. This watcher works on top of an isolated events PubSub.
func NewWatcher ¶
NewWatcher returns a new filesystem Watcher that publishes events to the given PubSub. Event names will follow the pattern `fs.<type>` where the type can be create, write, remove, rename or chmod. The event identifiers will be nil, and the event payload will be the filename.
Click to show internal directories.
Click to hide internal directories.