file

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	State State
	ID    uint64   // uuid
	Tasks sync.Map // map[taskid]*keyword.TaskConfig

	IsDeleted     bool // 标志位,记录文件是否已被删除,用来清理任务
	IsInactivated bool // 标志位,记录文件是否由于长期未写入数据,进入未激活状态,用来清理任务
}

func NewFile

func NewFile(filepath string, info os.FileInfo, inode uint64) (*File, error)

func (*File) AddTask

func (f *File) AddTask(t *keyword.TaskConfig)

func (*File) IsSameFile

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

IsSameFile Checks if the two files are the same.

func (*File) RmTask

func (f *File) RmTask(taskID string)

type State

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
	INode     uint64        `json:"-"` // the file inode
	Source    string        `json:"source"`
	Offset    int64         `json:"offset"`
	Timestamp time.Time     `json:"timestamp"`
	TTL       time.Duration `json:"ttl"`
	Inactive  int64         `json:"inactive"` // record time, how long time has no write(unit: minutes)
	Type      string        `json:"type"`
}

State is used to communicate the reading state of a file

func NewState

func NewState(fileInfo os.FileInfo, path string, t string) State

NewState creates a new file state

Jump to

Keyboard shortcuts

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