watcherconfig

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: AGPL-3.0 Imports: 11 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

Index

Constants

View Source
const DefaultScanInterval = Interval(5 * time.Second)

DefaultScanInterval is the duration between directory scans when none is specified in the config.

Variables

This section is empty.

Functions

func NewValidator

func NewValidator() *validator.Validate

NewValidator returns a validator configured with the mediatype validator and with runtime length-constraint rules derived from `jsonschema:"minLength=N"` tags on the watcher config struct types.

Types

type CompiledRegexp

type CompiledRegexp struct {
	*regexp.Regexp
}

CompiledRegexp is a Go regular expression that is compiled at YAML parse time. An invalid expression causes YAML unmarshaling (and therefore config loading) to fail with a descriptive error, so no separate validation step is required.

func (CompiledRegexp) JSONSchema

func (CompiledRegexp) JSONSchema() *jsonschema.Schema

JSONSchema returns a JSON Schema for CompiledRegexp. The type serialises as a scalar string (the regex pattern) at YAML parse time; reflecting the Go struct would produce an empty object schema, so this method overrides that to describe the on-disk shape accurately.

func (*CompiledRegexp) UnmarshalYAML

func (c *CompiledRegexp) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML compiles the scalar YAML string as a Go regular expression. It returns an error if the node is not a scalar string, if the string is empty, or if the expression is invalid.

type Config

type Config struct {
	// ScanInterval controls how often the watcher walks each configured watch directory.
	// Specified as a Go duration string (e.g. "5s", "1m30s"). Defaults to 5 seconds when omitted.
	ScanInterval Interval `yaml:"scanInterval,omitempty" validate:"gt=0"`
	// Watches lists the directories to monitor and their associated media types.
	Watches []WatchEntry `yaml:"watches,omitempty" validate:"dive"`
}

Config is the top-level watcher configuration loaded from the YAML config file.

func (*Config) SetDefaults

func (cfg *Config) SetDefaults()

SetDefaults implements defaults.Setter to initialize Config fields from package constants, avoiding duplicate literal values in struct tags.

type Interval added in v0.0.6

type Interval time.Duration

Interval is a Go duration parsed from a YAML scalar like "5s" or "1m30s". It exists because yaml.v3 does not natively understand time.Duration values.

func (Interval) Duration added in v0.0.6

func (i Interval) Duration() time.Duration

Duration returns the interval as a time.Duration for use with time.NewTicker etc.

func (Interval) JSONSchema added in v0.0.6

func (Interval) JSONSchema() *jsonschema.Schema

JSONSchema returns a JSON Schema describing the on-disk shape of Interval (a duration string).

func (Interval) MarshalYAML added in v0.0.6

func (i Interval) MarshalYAML() (any, error)

MarshalYAML emits the interval as its canonical Go duration string.

func (Interval) String added in v0.0.6

func (i Interval) String() string

String returns the canonical Go duration representation of the interval.

func (*Interval) UnmarshalYAML added in v0.0.6

func (i *Interval) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML parses a YAML scalar string as a Go duration. An explicit non-positive duration is rejected so it cannot silently fall back to the default in SetDefaults.

type WatchEntry

type WatchEntry struct {
	// Name is a human-readable label for this watch entry, used in logs and metrics.
	Name string `yaml:"name" jsonschema:"minLength=1"`
	// WatchedPath is the filesystem path to the directory to watch. Relative paths are resolved
	// against the watcher's working directory.
	WatchedPath string `yaml:"watchedPath" jsonschema:"minLength=1"`
	// MediaType indicates whether this directory contains movies or TV show episodes.
	MediaType medialib.MediaType `yaml:"mediaType" validate:"mediatype"`
	// IgnorePatterns is an optional list of Go regular expressions matched against the absolute
	// path of each file and directory encountered during a scan. A matching file is silently
	// skipped; a matching directory causes its entire subtree to be pruned. Patterns are
	// compiled when the configuration is loaded; an invalid expression causes configuration loading to fail.
	IgnorePatterns []CompiledRegexp `yaml:"ignorePatterns,omitempty" validate:"omitempty"`
	// PreserveSource controls whether the source file is deleted after successful processing.
	// When true, the source file is kept; when false or omitted, the source file is deleted
	// (default behaviour).
	PreserveSource bool `yaml:"preserveSource,omitempty"`
	// RetainEmptyDirectories controls whether empty parent directories are removed after the
	// source file is deleted. When false or omitted (the default), parent directories that
	// become empty as a result of source-file deletion are pruned bottom-up, stopping at the
	// watch root. When true, no directory removal is performed.
	RetainEmptyDirectories bool `yaml:"retainEmptyDirectories,omitempty"`
	// Output describes where processed files are written and how the output path is translated
	// for the arr service.
	Output WatchEntryOutput `yaml:"output"`
}

WatchEntry describes a watched location, mapping a filesystem path to a media type for dispatch and carrying a human-readable name for identification.

type WatchEntryOutput added in v0.0.3

type WatchEntryOutput struct {
	// Path is the filesystem path to the directory where processed files are written.
	Path string `yaml:"path" jsonschema:"minLength=1"`
	// RemotePath is the path by which the output directory is known to the arr service (Radarr/Sonarr).
	// Set this when the worker and the arr service mount the output volume at different paths.
	// When empty, no path translation is applied.
	RemotePath string `yaml:"remotePath,omitempty"`
}

WatchEntryOutput describes the output destination for a watch entry.

Jump to

Keyboard shortcuts

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