Documentation
¶
Index ¶
Constants ¶
const ( PollIntervalFast time.Duration = time.Millisecond * 15 PollIntervalSlow time.Duration = time.Millisecond * 150 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is the container for all the logic around tailing a single file
func NewFile ¶
func NewFile(filename string, opts ...FileConfig) (*File, error)
NewFile returns a new File for the given file with the given Config options
func (*File) Close ¶
Close is the implementation of the io.Closer interface with implemenation
This closes the File, which currently prevents any further reads from the tailer.
func (*File) Read ¶
Read is the implementation of the io.Reader interface below are the implemenation details
Read will return (0, io.EOF) to any call after the Reader is closed.
Future Note: This is not set in stone, I am torn between allowing the current buffer to be flushed by Read after Close() is called and its current behavior. However I have taken the conservative route and currently EOF all post-close writes.
type FileConfig ¶
FileConfig lets you change tailer.File objects, their primary use is as arguments to tailer.NewFile constructor, although they could be used later, but I don't suggest it
func NotifyOnChanges ¶
func NotifyOnChanges() FileConfig
NotifyOnChanges will cause Tailer to use the filesystem's notification system (inotify, kqueue, etc) to detect file rotations as well as when the file is written to. It will attempt to listen to all events for the directory the file is in (this is required in order to detect when the file is recreated), if it cannot it will listen directly to the file for write updates, and poll to detect when a file is rotated
Heads up, this is still a little flakey in terms of tests (from 0 -> 5% failure rate). I haven't seen any real world issues, but you may run into issues here. If you can get a reproduceable test case and send it to me that would be awesome :D
func PollForChanges ¶
func PollForChanges() FileConfig
PollForChanges will cause tailer to poll the file every PollIntervalFast for writes and PollIntervalSlow for rotations.
func ReadFromStart ¶
func ReadFromStart() FileConfig
ReadFromStart will set the tailer.File to read from the start of the file instead of its default of reading from the end
func SetBufferSize ¶
func SetBufferSize(i int) FileConfig
SetBufferSize sets the size of the internal ring buffer that tailers use to buffer reads and writes from disk