indexer

package
v1.0.41 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event uint
const (
	EventNone Event = iota
	EventAdd
	EventRemove
)

type Indexer

type Indexer struct {
	*walkfs.WalkFS
	*Queue
	// contains filtered or unexported fields
}

func NewIndexer

func NewIndexer(name, path string) (*Indexer, error)

Create a new indexer with an identifier, path to the root of the indexer and a channel to receive any errors

func (*Indexer) Name

func (i *Indexer) Name() string

Return name of the index

func (*Indexer) Path

func (i *Indexer) Path() string

Return the absolute path of the index

func (*Indexer) Run

func (i *Indexer) Run(ctx context.Context, errs chan<- error) error

run indexer

func (*Indexer) String

func (i *Indexer) String() string

func (*Indexer) Walk

func (i *Indexer) Walk(ctx context.Context, fn WalkFunc) error

Walk will initiate a walk of the index, and block until context is cancelled or walk is started

type Queue

type Queue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewQueueWithCapacity

func NewQueueWithCapacity(cap int) *Queue

Create a new queue which acts as a buffer between the file indexing and the rendering which can be slower than the file indexing

func (*Queue) Add

func (q *Queue) Add(name, path string)

Add an item to the queue. If the item is already in the queue, then it is bumped to the end of the queue

func (*Queue) Count

func (q *Queue) Count() int

Return a queue event from the head

func (*Queue) Get

func (q *Queue) Get(name, path string) *QueueEvent

Return a queue event from the queue, or nil

func (*Queue) Next

func (q *Queue) Next() *QueueEvent

Return a queue event from the head

func (*Queue) Remove

func (q *Queue) Remove(name, path string)

Remove an item to the queue. If the item is already in the queue, it is removed

func (*Queue) String

func (this *Queue) String() string

type QueueEvent

type QueueEvent struct {
	Event
	Name string
	Path string
}

type WalkFunc

type WalkFunc func(err error)

WalkFunc is called after a reindexing with any walk errors

Jump to

Keyboard shortcuts

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