tail

package
v0.1.3-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

definitions: tracker - the tracker keeps track of files being tailed via a single fsnotify watcher. Primary Workflow:

  1. initialize tracker
  2. add path(s)
  3. watch for fsnotify events
  4. exit when context is cancelled.

Directory Path Workflow:

  1. add path to watcher

file path workflow:

  1. add path to watcher
  2. initialize tailer struct
  3. start tailer

event workflow:

  • if event is create, add new file path.
  • if event is write, stop waiting
  • if event is delete, stop associated tailer (if it was file)

tail workflow:

  • read all lines from saved position
  • if eof, wait for changes

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChanClosedEmpty = errors.New("channel is closed or empty")
)

Functions

This section is empty.

Types

type LineProcessor

type LineProcessor = func(string, string) error

type Config struct{}

type PathInfo

type PathInfo struct {
	Events chan fsnotify.Event
	// contains filtered or unexported fields
}

func NewInfo

func NewInfo(path, dataDir string, processor LineProcessor) (*PathInfo, error)

func (*PathInfo) Done

func (p *PathInfo) Done()

func (*PathInfo) ReadLines

func (p *PathInfo) ReadLines() ([]string, error)

TODO - batch reads

func (*PathInfo) ReadUntilEOF

func (p *PathInfo) ReadUntilEOF()

func (*PathInfo) Run

func (p *PathInfo) Run()

type TailTracker

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

func NewTracker

func NewTracker(dataDir string) (*TailTracker, error)

func (*TailTracker) AddFromParent

func (t *TailTracker) AddFromParent(parent, name string) (*PathInfo, error)

func (*TailTracker) AddPath

func (t *TailTracker) AddPath(path string, processor LineProcessor) (*PathInfo, error)

AddPath adds the given path to the set of watched paths. If the path is a directory, files included in that directory will be added to the watcher as they are updated/created.

func (*TailTracker) Run

func (t *TailTracker) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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