fswatcher

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NotSpecified = iota
	DirectoryNotFound
	FileNotFound

	// The WinFileRemoved Error should never be seen, because it is handled internally in the FileTailer.
	// TODO: Refactor error handling such that this is not part of the public interface.
	WinFileRemoved
)

Variables

This section is empty.

Functions

func NewLineReader

func NewLineReader() *lineReader

Types

type Dir

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

func (*Dir) Path

func (d *Dir) Path() string

type Error

type Error interface {
	Cause() error
	Type() ErrorType
	error
}

func NewError

func NewError(errorType ErrorType, cause error, msg string) Error

func NewErrorf

func NewErrorf(errorType ErrorType, cause error, format string, a ...interface{}) Error

type ErrorType

type ErrorType int

type File

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

File implementation that closes the file after each operation, in order to avoid "the file is in use by another process" errors on Windows. Note: Even if we use the FILE_SHARE_DELETE flag while opening the file, it is not save to keep it open. If another program deletes the file (like logrotate), the file will remain in the directory until grok_exporter closes it. In order to avoid this, we must not keep the file open.

func NewFile

func NewFile(orig *File, newPath string) *File

like os.NewFile()

func (*File) CheckMoved

func (f *File) CheckMoved() (bool, error)

func (*File) CheckTruncated

func (f *File) CheckTruncated() (bool, Error)

func (*File) Close

func (f *File) Close() error

func (*File) Fd

func (f *File) Fd() uintptr

func (*File) Name

func (f *File) Name() string

func (*File) Read

func (f *File) Read(b []byte) (int, error)

TODO: error handling is confusing. in case of EOF must return io.EOF, because linereader expects that. in case of WinFileMoved, must return special error to trigger sync dir.

func (*File) SameFile

func (f *File) SameFile(other *File) bool

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, Error)

type FileTailer

type FileTailer interface {
	Lines() chan Line
	Errors() chan Error
	Close()
}

func RunFileTailer

func RunFileTailer(globs []glob.Glob, readall bool, failOnMissingFile bool, log logrus.FieldLogger) (FileTailer, error)

func RunPollingFileTailer

func RunPollingFileTailer(globs []glob.Glob, readall bool, failOnMissingFile bool, pollInterval time.Duration, log logrus.FieldLogger) (FileTailer, error)

type Line

type Line struct {
	Line string
	File string
}

Jump to

Keyboard shortcuts

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