monitor

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileMonitor

type FileMonitor struct {
	// log
	Log zerolog.Logger
	// list of subscribers and their states
	Subsciptions []Subscription
}

FileMonitor detects changes since the last check and notifies subscribers

func (*FileMonitor) Monitor

func (m *FileMonitor) Monitor()

Check if changes in files require any action

func (*FileMonitor) Run

func (m *FileMonitor) Run(watcher *fsnotify.Watcher)

Run activates a go routine that calls Monitor() upon changes in $DATA_DIR/adminconfig directory where DATA_DIR environment variable defines the root directory of the data.

func (*FileMonitor) Subscribe

func (m *FileMonitor) Subscribe(subscriber Subscriber) error

Subscribe to get notifications on file changes

type FileMonitorOptions

type FileMonitorOptions struct {
	// Directory that should be monitored for change
	Path string
	// File extension
	Extension string
}

type Subscriber

type Subscriber interface {
	GetOptions() FileMonitorOptions
	OnError(err error)
	OnNotify()
}

type Subscription

type Subscription struct {
	Entity       Subscriber
	Options      FileMonitorOptions
	LastModified time.Time
	NumFiles     int
}

Jump to

Keyboard shortcuts

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