Documentation
¶
Overview ¶
Package mediapresence decides whether a media file is gone or only unreachable. A file is gone only when the filesystem says it does not exist and the bound media root holding it is present, readable and not empty: an unmounted share usually leaves an empty mountpoint, so an empty root reads as unreachable rather than as every file under it deleted. Any other failure, including a filesystem call that outlives the timeout, is a fault of the root; while one is recorded it is reported once at ERROR, as a persistent alert and as the media_root_unavailable gauge of that root.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrOutsideRoots = errors.New("path is outside every media root")
ErrOutsideRoots reports a path no bound media root contains, whose absence therefore proves nothing.
ErrUnavailable matches every *UnavailableError.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker is the process-wide judge of media file absence. It is safe for concurrent use.
func New ¶
New builds a Checker; it fails only when Metrics or Alerts is missing, a nil pointer in either interface included.
func (*Checker) Bind ¶
Bind installs the configured media roots. It runs on every activation: a new root's gauge starts at 0, and a removed root loses its fault, alert and series. Before the first Bind every path is outside the roots.
func (*Checker) Gone ¶
Gone reports whether path definitely no longer exists. A false with a nil error means it exists. A non-nil error means nothing can be concluded and nothing may be deleted on its strength: ErrOutsideRoots, an *UnavailableError, or ctx's error when ctx ended first. While a root is faulted every path under it but the one that faulted it is unavailable, so only that path's check can clear the fault.
type Config ¶
type Config struct {
Metrics metrics
Alerts alerts
Stat func(path string) (fs.FileInfo, error) // nil: os.Stat
// HasEntries reports whether a directory holds at least one entry; nil
// reads one name.
HasEntries func(dir string) (bool, error)
Timeout time.Duration // 0: 10s, per filesystem call
RecheckInterval time.Duration // 0: 5m, the background recheck period
}
Config configures a Checker. Metrics and Alerts are required; every other zero field takes its documented default.
type UnavailableError ¶
type UnavailableError struct {
}
UnavailableError reports that Path could not be judged because Root, the bound root holding it, is faulted; Err is the failure that decided it.
func (*UnavailableError) Error ¶
func (e *UnavailableError) Error() string
func (*UnavailableError) Unwrap ¶
func (e *UnavailableError) Unwrap() []error
Unwrap exposes ErrUnavailable and the underlying error.