beats: Index | Files

package file

import ""


Package Files

file.go glob.go state.go states.go

func Glob Uses

func Glob(pattern string, doubleStarPatternDepth uint8) ([]string, error)

Glob expands '**' patterns into multiple patterns to satisfy

func GlobPatterns Uses

func GlobPatterns(pattern string, doubleStarPatternDepth uint8) ([]string, error)

GlobPatterns detects the use of "**" and expands it to standard glob patterns up to a max depth

func IsSameFile Uses

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

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

type File Uses

type File struct {
    File     *os.File
    FileInfo os.FileInfo
    Path     string
    State    *State

func (*File) IsSameFile Uses

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

Checks if the two files are the same.

type State Uses

type State struct {
    Id          string            `json:"-"` // local unique id to make comparison more efficient
    Finished    bool              `json:"-"` // harvester state
    Fileinfo    os.FileInfo       `json:"-"` // the file info
    Source      string            `json:"source"`
    Offset      int64             `json:"offset"`
    Timestamp   time.Time         `json:"timestamp"`
    TTL         time.Duration     `json:"ttl"`
    Type        string            `json:"type"`
    Meta        map[string]string `json:"meta"`
    FileStateOS file.StateOS

State is used to communicate the reading state of a file

func NewState Uses

func NewState(fileInfo os.FileInfo, path string, t string, meta map[string]string) State

NewState creates a new file state

func (*State) ID Uses

func (s *State) ID() string

ID returns a unique id for the state as a string

func (*State) IsEmpty Uses

func (s *State) IsEmpty() bool

IsEmpty returns true if the state is empty

func (*State) IsEqual Uses

func (s *State) IsEqual(c *State) bool

IsEqual compares the state to an other state supporting stringer based on the unique string

type States Uses

type States struct {
    // contains filtered or unexported fields

States handles list of FileState. One must use NewStates to instantiate a file states registry. Using the zero-value is not safe.

func NewStates Uses

func NewStates() *States

NewStates generates a new states registry.

func (*States) Cleanup Uses

func (s *States) Cleanup() (int, int)

Cleanup cleans up the state array. All states which are older then `older` are removed The number of states that were cleaned up and number of states that can be cleaned up in the future is returned.

func (*States) Copy Uses

func (s *States) Copy() *States

Copy create a new copy of the states object

func (*States) Count Uses

func (s *States) Count() int

Count returns number of states

func (*States) FindPrevious Uses

func (s *States) FindPrevious(newState State) State

FindPrevious lookups a registered state, that matching the new state. Returns a zero-state if no match is found.

func (*States) GetStates Uses

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

GetStates creates copy of the file states.

func (*States) SetStates Uses

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

SetStates overwrites all internal states with the given states array

func (*States) Update Uses

func (s *States) Update(newState State)

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

func (*States) UpdateWithTs Uses

func (s *States) UpdateWithTs(newState State, ts time.Time)

UpdateWithTs updates a state, assigning the given timestamp. If previous state didn't exist, new one is created

Package file imports 10 packages (graph) and is imported by 493 packages. Updated 2018-08-19. Refresh now. Tools for package owners.