watcher

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: GPL-3.0 Imports: 9 Imported by: 0 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

Overview

Package watcher provides file system monitoring functionality for the GitCells application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IgnorePatterns []string
	DebounceDelay  time.Duration
	FileExtensions []string
}

type Debouncer

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

Debouncer prevents rapid successive calls by delaying execution

func NewDebouncer

func NewDebouncer(delay time.Duration) *Debouncer

NewDebouncer creates a new debouncer with the specified delay

func (*Debouncer) Cancel

func (d *Debouncer) Cancel(key string)

Cancel cancels the debounced function for the given key

func (*Debouncer) CancelAll

func (d *Debouncer) CancelAll()

CancelAll cancels all pending debounced functions

func (*Debouncer) Debounce

func (d *Debouncer) Debounce(key string, fn func())

Debounce delays the execution of fn until delay has passed since the last call

func (*Debouncer) GetDelay

func (d *Debouncer) GetDelay() time.Duration

GetDelay returns the current delay setting

func (*Debouncer) GetPendingKeys

func (d *Debouncer) GetPendingKeys() []string

GetPendingKeys returns all keys that have pending debounced functions

func (*Debouncer) HasPending

func (d *Debouncer) HasPending() bool

HasPending returns true if there are any pending debounced functions

func (*Debouncer) SetDelay

func (d *Debouncer) SetDelay(delay time.Duration)

SetDelay updates the delay for future debounce calls

type EventHandler

type EventHandler func(event FileEvent) error

type EventType

type EventType int
const (
	EventTypeCreate EventType = iota
	EventTypeModify
	EventTypeDelete
)

func (EventType) String

func (et EventType) String() string

type FileEvent

type FileEvent struct {
	Path      string
	Type      EventType
	Timestamp time.Time
}

type FileWatcher

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

func NewFileWatcher

func NewFileWatcher(config *Config, handler EventHandler, logger *logrus.Logger) (*FileWatcher, error)

func (*FileWatcher) AddDirectory

func (fw *FileWatcher) AddDirectory(path string) error

func (*FileWatcher) GetWatchedDirectories

func (fw *FileWatcher) GetWatchedDirectories() []string

func (*FileWatcher) IsWatching

func (fw *FileWatcher) IsWatching(path string) bool

func (*FileWatcher) RemoveDirectory

func (fw *FileWatcher) RemoveDirectory(path string) error

func (*FileWatcher) Start

func (fw *FileWatcher) Start() error

func (*FileWatcher) Stop

func (fw *FileWatcher) Stop() error

Jump to

Keyboard shortcuts

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