modtime

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicatePath = errors.New("duplicate path")
	ErrPathNotFound  = errors.New("path not found")
)
View Source
var (
	// DefaultStatFS is the default Stat FileSystem to monitor paths,
	// which is the host Unix filesystem rooted at "/"
	DefaultStatFS = os.DirFS("/").(fs.StatFS)

	// DefaultCheckInterval is the default interval for checking paths' modtimes
	DefaultCheckInterval = time.Minute * 5
)

Functions

func CleanPath

func CleanPath(pathStr string) string

CleanPath cleans and trimspaces path strings

Types

type ModTimeMonitor

type ModTimeMonitor struct {
	sync.RWMutex // used to synchronize changes to the set of paths being monitored
	// contains filtered or unexported fields
}

ModTimeMonitor monitors the modtimes for a set of paths in a filesystem

func NewModTimeMonitor

func NewModTimeMonitor(ctx context.Context, opts ...Option) *ModTimeMonitor

NewModTimeMonitor returns a new ModTimeMonitor with a background monitoring thread already started

func (*ModTimeMonitor) AddMonitoredPath

func (mtm *ModTimeMonitor) AddMonitoredPath(strategyStr, pathStr string, opts ...Option) error

AddMonitoredPath adds a path to be monitored for modtime changes

func (*ModTimeMonitor) GetPathStatus

func (mtm *ModTimeMonitor) GetPathStatus(strategyStr, pathStr string) (*PathStatus, error)

GetPathStatus returns the current status of a monitored path

type Option

type Option func(*mtmOptions)

func WithCheckInterval

func WithCheckInterval(checkIntv time.Duration) Option

WithCheckInterval is the option to set the check interval (how often to check modtimes)

func WithErrLogger added in v1.7.0

func WithErrLogger(errlog logger.Logger) Option

WithErrLogger is the option to set the Logger

func WithLogger

func WithLogger(log logger.Logger) Option

WithLogger is the option to set the Logger

func WithStatFS

func WithStatFS(statFS fs.StatFS) Option

WithStatFS is the option to set the Stat FileSystem

type PathStatus

type PathStatus struct {
	StrategyStr string
	PathStr     string
	ModTime     time.Time
}

PathStatus holds status of a monitored path, returned by GetPathStatus()

Jump to

Keyboard shortcuts

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