fs

package
v3.11.4 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

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

func Watch

func Watch(name string, handler events.Handler) error

Watch a file on the default filesystem Watcher. The handler may be nil.

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

func NewWatcher(pubsub events.PubSub) (Watcher, error)

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.

Jump to

Keyboard shortcuts

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