readers

package
v0.1.8-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLastSeparatorPosition

func GetLastSeparatorPosition(fileHandler io.ReadSeeker) int64

GetLastSeparatorPosition returns first occurrence of '\n', reading file chunk by chunk from the end returns zero in case of IO errors (unlikely) or missing separator note: does not keep current file cursor for easiness’ sake

func JournaldPath

func JournaldPath(machineIDPath, journaldPath string) (string, error)

JournaldPath tries to construct path to system journal from machine ID and base path

Types

type Cursor

type Cursor struct {
	Inode  uint64
	Device uint64
	Value  int64
}

Cursor position in file

func NewCursorFromString

func NewCursorFromString(cursorString string) (*Cursor, error)

NewCursorFromString is a constructor

func (*Cursor) String

func (cursor *Cursor) String() string

String Cursor representation

type LineReader

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

LineReader is used for reading lines from file. Signals about rotations (fs notify rename)

func NewLineReader

func NewLineReader(filePath string, bufferSize int, initialCursor *Cursor, fromTailFlag bool) (*LineReader, error)

NewLineReader is a constructor for LineReader

func (*LineReader) Close

func (reader *LineReader) Close() error

Close should be used as LineReader finalizer

func (*LineReader) EntryRead

func (reader *LineReader) EntryRead() ([]byte, bool, error)

EntryRead returns one line from file, cutting off line ending if it's not the last line and tries to handle rotation

func (*LineReader) GetAcquireFlag

func (reader *LineReader) GetAcquireFlag() bool

GetAcquireFlag should be used to check if ReaderJournald is able to provide data

func (*LineReader) GetCursor

func (reader *LineReader) GetCursor() *Cursor

GetCursor should be used to get current reader in-memory cursor

type ReaderJournald

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

ReaderJournald is not ReaderJournald in Go stdlib sense. Postponed naming issue.

func NewReaderJournald

func NewReaderJournald(journalPath string, initialCursor string) (*ReaderJournald, error)

NewReaderJournald is a constructor for ReaderJournald instance

func (*ReaderJournald) Close

func (reader *ReaderJournald) Close() error

Close should be used as reader finalizer

func (*ReaderJournald) EntryRead

func (reader *ReaderJournald) EntryRead() (common.EntryMap, error)

EntryRead gets new entry

func (*ReaderJournald) GetAcquireFlag

func (reader *ReaderJournald) GetAcquireFlag() bool

GetAcquireFlag should be used for checking if reader is ready

func (*ReaderJournald) GetCursor

func (reader *ReaderJournald) GetCursor() string

GetCursor should be used to get current reader in-memory cursor; journald cursor is not so complex as lineReader's one, so it's just a string

Jump to

Keyboard shortcuts

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