input

package
v5.0.0-alpha3+incompat... Latest Latest
Warning

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

Go to latest
Published: May 31, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRegularFile

func IsRegularFile(file *os.File) bool

func IsSameFile

func IsSameFile(path string, info os.FileInfo) bool

IsSameFile checks if the given File path corresponds with the FileInfo given

func ReadOpen

func ReadOpen(path string) (*os.File, error)

ReadOpen opens a file for reading only

func SafeFileRotate

func SafeFileRotate(path, tempfile string) error

SafeFileRotate safely rotates an existing file under path and replaces it with the tempfile

Types

type File

type File struct {
	File      *os.File
	FileInfo  os.FileInfo
	Path      string
	FileState *FileState
}

func (*File) IsRegularFile

func (f *File) IsRegularFile() bool

Check that the file isn't a symlink, mode is regular or file is nil

func (*File) IsSameFile

func (f *File) IsSameFile(f2 *File) bool

Checks if the two files are the same.

type FileEvent

type FileEvent struct {
	common.EventMetadata
	ReadTime     time.Time
	Source       string
	InputType    string
	DocumentType string
	Offset       int64
	Bytes        int
	Text         *string
	Fileinfo     os.FileInfo
	JSONFields   common.MapStr
	JSONConfig   *JSONConfig
	FileState    FileState
}

FileEvent is sent to the output and must contain all relevant information

func (*FileEvent) ToMapStr

func (f *FileEvent) ToMapStr() common.MapStr

type FileState

type FileState struct {
	Source      string      `json:"source"`
	Offset      int64       `json:"offset"`
	Finished    bool        `json:"-"` // harvester state
	Fileinfo    os.FileInfo `json:"-"` // the file info
	FileStateOS FileStateOS
	LastSeen    time.Time `json:"last_seen"`
}

FileState is used to communicate the reading state of a file

func NewFileState

func NewFileState(fileInfo os.FileInfo, path string) FileState

NewFileState creates a new file state

type FileStateOS

type FileStateOS struct {
	Inode  uint64 `json:"inode,"`
	Device uint64 `json:"device,"`
}

func GetOSFileState

func GetOSFileState(info os.FileInfo) FileStateOS

GetOSFileState returns the FileStateOS for non windows systems

func (FileStateOS) IsSame

func (fs FileStateOS) IsSame(state FileStateOS) bool

IsSame file checks if the files are identical

type JSONConfig

type JSONConfig struct {
	MessageKey    string `config:"message_key"`
	KeysUnderRoot bool   `config:"keys_under_root"`
	OverwriteKeys bool   `config:"overwrite_keys"`
	AddErrorKey   bool   `config:"add_error_key"`
}

type MultilineConfig

type MultilineConfig struct {
	Negate   bool           `config:"negate"`
	Match    string         `config:"match"       validate:"required"`
	MaxLines *int           `config:"max_lines"`
	Pattern  *regexp.Regexp `config:"pattern"`
	Timeout  *time.Duration `config:"timeout"     validate:"positive"`
}

func (*MultilineConfig) Validate

func (c *MultilineConfig) Validate() error

type States

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

States handles list of FileState

func NewStates

func NewStates() *States

func (*States) Cleanup

func (s *States) Cleanup(older time.Duration)

Cleanup cleans up the state array. All states which are older then `older` are removed

func (*States) Copy

func (s *States) Copy() *States

Copy create a new copy of the states object

func (*States) Count

func (s *States) Count() int

Count returns number of states

func (*States) FindPrevious

func (s *States) FindPrevious(newState FileState) (int, FileState)

func (*States) GetStates

func (s *States) GetStates() []FileState

Returns a copy of the file states

func (*States) SetStates

func (s *States) SetStates(states []FileState)

SetStates overwrites all internal states with the given states array

func (*States) Update

func (s *States) Update(newState FileState)

Update updates a state. If previous state didn't exist, new one is created

Jump to

Keyboard shortcuts

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