file_state_handler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileFilter

type FileFilter func(string, FileState) bool

FileFilter type for file filtering.

func FilterIsCollecting

func FilterIsCollecting() FileFilter

FilterIsCollecting returns a filter that matches files that are being collected.

func FilterIsListening

func FilterIsListening() FileFilter

FilterIsListening returns a filter that matches files that are being listened to.

func FilterReadyToProcess

func FilterReadyToProcess() FileFilter

FilterReadyToProcess returns a filter that matches files that are ready to process.

func FilterTime

func FilterTime(startTime, endTime int64) FileFilter

FilterTime returns a filter that matches files that have intervals overlapping with the given time.

type FileState

type FileState struct {
	Size         int64        `json:"size"`
	StartTime    int64        `json:"start_time,omitempty"`
	EndTime      int64        `json:"end_time,omitempty"`
	Unsupported  bool         `json:"unsupported,omitempty"`
	IsDir        bool         `json:"is_dir,omitempty"`
	IsListening  bool         `json:"is_listening,omitempty"`
	IsCollecting bool         `json:"is_collecting,omitempty"`
	ProcessState processState `json:"process_state,omitempty"`
	TooOld       bool         `json:"too_old,omitempty"`
	Pathname     string       `json:"-"` // Pathname is output only for the Files method
}

FileState represents the state of a file in the system.

type FileStateHandler

type FileStateHandler interface {
	// UpdateDirs updates the directories being monitored.
	UpdateDirs(conf config.DefaultModConfConfig) error

	// Files returns filename and filestate pairs that match the given filters.
	Files(filters ...FileFilter) []FileState

	// UpdateFilesProcessState updates the state of files that are ready to process.
	// This should be called before processing files
	UpdateFilesProcessState() error

	// MarkProcessedFile updates the state of files that were ready to process
	// to mark them as processed.
	MarkProcessedFile(filename string) error

	// GetFileHandler returns the handler for a given file path.
	GetFileHandler(filePath string) file_handlers.Interface
}

FileStateHandler is the interface for the file state handler.

func New

func New() (FileStateHandler, error)

New returns the singleton instance of fileStateHandler.

type SavedState

type SavedState struct {
	State      map[string]FileState `json:"state"`
	SrcDirs    []string             `json:"src_dirs"`
	ListenDirs []string             `json:"listen_dirs"`
}

SavedState represents the complete state to be saved to disk.

Jump to

Keyboard shortcuts

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