watch

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Copyright (c) 2019 FOSS contributors of https://github.com/bloominlabs/tail

Index

Constants

This section is empty.

Variables

View Source
var POLL_DURATION time.Duration

Functions

func Cleanup

func Cleanup(filename string) error

func RemoveWatcher

func RemoveWatcher(watcher Watcher) error

Types

type FileChanges

type FileChanges struct {
	Modified  chan bool // Channel to get notified of modifications
	Truncated chan bool // Channel to get notified of truncations
	Deleted   chan bool // Channel to get notified of deletions/renames
}

func NewFileChanges

func NewFileChanges() *FileChanges

func (*FileChanges) NotifyDeleted

func (fc *FileChanges) NotifyDeleted()

func (*FileChanges) NotifyModified

func (fc *FileChanges) NotifyModified()

func (*FileChanges) NotifyTruncated

func (fc *FileChanges) NotifyTruncated()

type FileWatcher

type FileWatcher interface {
	// BlockUntilExists blocks until the file comes into existence.
	BlockUntilExists(*tomb.Tomb) error

	// ChangeEvents reports on changes to a file, be it modification,
	// deletion, renames or truncations. Returned FileChanges group of
	// channels will be closed, thus become unusable, after a deletion
	// or truncation event.
	// In order to properly report truncations, ChangeEvents requires
	// the caller to pass their current offset in the file.
	ChangeEvents(*tomb.Tomb, int64) (*FileChanges, error)
}

FileWatcher monitors file-level events.

type InotifyFileWatcher

type InotifyFileWatcher struct {
	Filename string
	Size     int64
}

InotifyFileWatcher uses inotify to monitor file changes.

func NewInotifyFileWatcher

func NewInotifyFileWatcher(filename string) *InotifyFileWatcher

func (*InotifyFileWatcher) BlockUntilExists

func (fw *InotifyFileWatcher) BlockUntilExists(t *tomb.Tomb) error

func (*InotifyFileWatcher) ChangeEvents

func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error)

type InotifyTracker

type InotifyTracker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type PollingFileWatcher

type PollingFileWatcher struct {
	Filename string
	Size     int64
}

PollingFileWatcher polls the file for changes.

func NewPollingFileWatcher

func NewPollingFileWatcher(filename string) *PollingFileWatcher

func (*PollingFileWatcher) BlockUntilExists

func (fw *PollingFileWatcher) BlockUntilExists(t *tomb.Tomb) error

func (*PollingFileWatcher) ChangeEvents

func (fw *PollingFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error)

type Watcher

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

func CreateWatcher

func CreateWatcher(filename string) (Watcher, error)

Watch signals the run goroutine to begin watching the input filename

Jump to

Keyboard shortcuts

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