Documentation ¶
Overview ¶
************************************************************************
- Copyright 2017 Gravwell, Inc. All rights reserved.
- Contact: <legal@gravwell.io> *
- This software may be modified and distributed under the terms of the
- BSD 2-clause license. See the LICENSE file for details. *************************************************************************
Index ¶
- Constants
- Variables
- func NewFollower(cfg FollowerConfig) (*follower, error)
- func ReadStateFile(p string) (states map[string]int64, err error)
- type FileId
- type FileName
- type FilterManager
- func (f *FilterManager) AddFilter(bname, loc string, mtchs []string, lh handler, ecfg FollowerEngineConfig) error
- func (fm *FilterManager) Close() (err error)
- func (fm *FilterManager) Filters() int
- func (fm *FilterManager) FlushStates() error
- func (fm *FilterManager) Followed() int
- func (f *FilterManager) IsWatched(fpath string) bool
- func (f *FilterManager) LoadFile(fpath string) (bool, error)
- func (f *FilterManager) NewFollower(fpath string) (bool, error)
- func (f *FilterManager) RemoveFollower(fpath string) (bool, error)
- func (f *FilterManager) RenameFollower(fpath string) error
- func (fm *FilterManager) SetLogger(lgr ingest.IngestLogger)
- func (fm *FilterManager) SetMaxFilesWatched(max int)
- type FollowerConfig
- type FollowerEngineConfig
- type LineReader
- type LogHandler
- type LogHandlerConfig
- type Reader
- type ReaderConfig
- type RegexReader
- type WatchConfig
- type WatchManager
- func (wm *WatchManager) Add(c WatchConfig) error
- func (wm *WatchManager) Close() error
- func (wm *WatchManager) Dump() string
- func (wm *WatchManager) Filters() int
- func (wm *WatchManager) Followers() int
- func (wm *WatchManager) SetLogger(lgr ingest.IngestLogger)
- func (wm *WatchManager) SetMaxFilesWatched(max int)
- func (wm *WatchManager) Start() error
Constants ¶
const ( LineEngine int = 0 RegexEngine int = 1 )
Variables ¶
var ( ErrNotReady = errors.New("fsnotify watcher is not ready") ErrLocationNotDir = errors.New("Watched Location is not a directory") ErrNoDirsWatched = errors.New("No locations have been added to the watch list") ErrInvalidStateFile = errors.New("State file exists and is not a regular file") ErrAlreadyStarted = errors.New("WatchManager already started") ErrFailedSeek = errors.New("Failed to seek to the start of the states file") )
var (
ErrNotRunning = errors.New("Not running")
)
Functions ¶
func NewFollower ¶
func NewFollower(cfg FollowerConfig) (*follower, error)
Types ¶
type FilterManager ¶
type FilterManager struct {
// contains filtered or unexported fields
}
func NewFilterManager ¶
func NewFilterManager(stateFile string) (*FilterManager, error)
func (*FilterManager) AddFilter ¶
func (f *FilterManager) AddFilter(bname, loc string, mtchs []string, lh handler, ecfg FollowerEngineConfig) error
func (*FilterManager) Close ¶
func (fm *FilterManager) Close() (err error)
func (*FilterManager) Filters ¶
func (fm *FilterManager) Filters() int
Filters returns the current number of installed filters
func (*FilterManager) FlushStates ¶
func (fm *FilterManager) FlushStates() error
FlushStates flushes the current state of followed files to the disk periodically flushing states is a good idea, incase the device crashes, or the process is abruptly killed
func (*FilterManager) Followed ¶
func (fm *FilterManager) Followed() int
Followed returns the current number of following handles if a file matches multiple filters, it will be followed multiple times. So this is NOT the number of files, but the number of follows
func (*FilterManager) IsWatched ¶
func (f *FilterManager) IsWatched(fpath string) bool
func (*FilterManager) NewFollower ¶
func (f *FilterManager) NewFollower(fpath string) (bool, error)
func (*FilterManager) RemoveFollower ¶
func (f *FilterManager) RemoveFollower(fpath string) (bool, error)
func (*FilterManager) RenameFollower ¶
func (f *FilterManager) RenameFollower(fpath string) error
RenameFollower is designed to rename a file that is currently being followed We first grab the file id that matches the given fpath Then we scan the base directory for ALL files and attempt to match the fileId if a match is found, we check if it matches the current filter, if not, we delete the follower if it does, we update the name and leave. If no match is found, we delete the follower
func (*FilterManager) SetLogger ¶
func (fm *FilterManager) SetLogger(lgr ingest.IngestLogger)
func (*FilterManager) SetMaxFilesWatched ¶
func (fm *FilterManager) SetMaxFilesWatched(max int)
type FollowerConfig ¶
type FollowerConfig struct { FollowerEngineConfig BaseName string FilePath string State *int64 FilterID int Handler handler }
type FollowerEngineConfig ¶
type LineReader ¶
type LineReader struct {
// contains filtered or unexported fields
}
func NewLineReader ¶
func NewLineReader(cfg ReaderConfig) (*LineReader, error)
type LogHandler ¶
type LogHandler struct { LogHandlerConfig // contains filtered or unexported fields }
func NewLogHandler ¶
func NewLogHandler(cfg LogHandlerConfig, ch chan *entry.Entry) (*LogHandler, error)
type LogHandlerConfig ¶
type Reader ¶
type Reader interface { SeekFile(int64) error ReadEntry() ([]byte, bool, bool, error) Index() int64 Close() error }
func NewReader ¶
func NewReader(cfg ReaderConfig) (Reader, error)
type ReaderConfig ¶
type RegexReader ¶
type RegexReader struct {
// contains filtered or unexported fields
}
func NewRegexReader ¶
func NewRegexReader(cfg ReaderConfig) (*RegexReader, error)
type WatchConfig ¶
type WatchConfig struct { FollowerEngineConfig ConfigName string BaseDir string FileFilter string Hnd handler Recursive bool }
type WatchManager ¶
type WatchManager struct {
// contains filtered or unexported fields
}
func NewWatcher ¶
func NewWatcher(stateFilePath string) (*WatchManager, error)
func (*WatchManager) Add ¶
func (wm *WatchManager) Add(c WatchConfig) error
func (*WatchManager) Close ¶
func (wm *WatchManager) Close() error
func (*WatchManager) Dump ¶
func (wm *WatchManager) Dump() string
Returns a string containing information about the WatchManager
func (*WatchManager) Filters ¶
func (wm *WatchManager) Filters() int
func (*WatchManager) Followers ¶
func (wm *WatchManager) Followers() int
func (*WatchManager) SetLogger ¶
func (wm *WatchManager) SetLogger(lgr ingest.IngestLogger)
func (*WatchManager) SetMaxFilesWatched ¶
func (wm *WatchManager) SetMaxFilesWatched(max int)
func (*WatchManager) Start ¶
func (wm *WatchManager) Start() error