worker

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFileRead means file read error.
	ErrFileRead = errors.New("worker: file read error")

	// ErrYrScan means yr scan error.
	ErrYrScan = errors.New("worker: yr scan error")
)

Functions

func MatchesToString

func MatchesToString(matches yr.MatchRules) []string

MatchesToString returns a slice string from given yr.MatcheRules.

Types

type Worker

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

Worker represents a job worker. isExpired is optimisation for if max age check is disabled. blkSz unit is byte. expiry unit is day.

func Mock

func Mock(env *env.Env) (*Worker, error)

Mock mocks a worker.

func New

func New(cfg *base.Cfg, rules *yr.Rules, maxAge int) (*Worker, error)

New returns a worker from given cfg, rules and max file age.

func (*Worker) Scan

func (worker *Worker) Scan(path string, result *state.Job)

Scan scans a given file path to a channel of data blocks. Errs are stored as mutex based concurrent data structure.

func (*Worker) Work

func (worker *Worker) Work(ctx context.Context, state *state.Job, queue chan string)

Work receives given queued paths to scan.

Jump to

Keyboard shortcuts

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