indexer

package
v1.0.29 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewError

func NewError(name string, err error) *event

func NewEvent

func NewEvent(t EventType, name, path string, info fs.FileInfo) *event

Types

type EventType

type EventType int
const (
	EVENT_TYPE_ADDED EventType = (1 << iota)
	EVENT_TYPE_REMOVED
	EVENT_TYPE_RENAMED
	EVENT_TYPE_CHANGED
	EVENT_TYPE_NONE EventType = 0
	EVENT_TYPE_MIN            = EVENT_TYPE_ADDED
	EVENT_TYPE_MAX            = EVENT_TYPE_CHANGED
)

func (EventType) FlagString

func (v EventType) FlagString() string

func (EventType) String

func (f EventType) String() string

type File

type File struct {
	Index   string    `sqlite:"index,primary" json:"index"`
	Path    string    `sqlite:"path,primary" json:"path"`
	Name    string    `sqlite:"name,primary" json:"name"`
	IsDir   bool      `sqlite:"is_dir,not null" json:"is_dir"`
	Ext     string    `sqlite:"ext" json:"ext"`
	ModTime time.Time `sqlite:"modtime" json:"modtime"`
	Size    int64     `sqlite:"size,not null" json:"size"`
}

func NewFile

func NewFile(evt IndexerEvent, write bool) *File

NewFile creates a file object from an event

func (*File) String

func (this *File) String() string

type FileMark

type FileMark struct {
	Index     string    `sqlite:"index,primary,foreign"`
	Path      string    `sqlite:"path,primary,foreign"`
	Name      string    `sqlite:"name,primary,foreign"`
	Mark      bool      `sqlite:"mark,not null"`
	IndexTime time.Time `sqlite:"idxtime"`
}

func NewFileMark

func NewFileMark(index, path, name string) *FileMark

NewFileMark creates an empty filemark object

type Indexer

type Indexer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewIndexer

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

func (*Indexer) Delta

func (this *Indexer) Delta() time.Duration

Get how often rendering is performed

func (*Indexer) Name

func (this *Indexer) Name() string

Return name of the index

func (*Indexer) Path

func (this *Indexer) Path() string

Return the absolute path of the index

func (*Indexer) SetDelta

func (this *Indexer) SetDelta(delta time.Duration)

Set how often rendering is performed

func (*Indexer) State

func (this *Indexer) State() IndexerState

Return the indexer state

func (*Indexer) String

func (this *Indexer) String() string

type IndexerEvent

type IndexerEvent interface {
	Name() string
	Type() EventType
	FileInfo() fs.FileInfo
	Path() string
	Err() error
}

type IndexerState

type IndexerState uint
const (
	IndexerStateIdle IndexerState = iota
	IndexerStateReindexing
	IndexerStateRunning
	IndexerStateSuspended
)

func (IndexerState) String

func (v IndexerState) String() string

type Manager

type Manager struct {
	SQObjects
	// contains filtered or unexported fields
}

func NewManager

func NewManager(conn SQConnection, schema string, flags SQFlag) (*Manager, error)

Create a new index manager object with a sqlite connection. Add SQLITE_FLAG_DELETEIFEXISTS to clear out existing tables

func (*Manager) Exclude

func (this *Manager) Exclude(idx *Indexer, exclusion string) error

Exclude adds a path or file extension exclusion to an index, removing any existing files which match these exclusions. If the exclusion begins with a '.' then a file extension exlusion is added, if it begins with a '/' then a path prefix exclusion is added. Path prefix exclusions are case-sensitive, file extension exclusions are not.

func (*Manager) NewIndexer

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

NewIndexer adds a file indexer and initiates walking the file tree

func (*Manager) Reindex

func (this *Manager) Reindex(indexer *Indexer) error

Reindex starts a reindex process to pick up new documents and delete old ones which are not in the index. A reindexing can only start when the indexer is in running state

func (*Manager) Run

func (this *Manager) Run(ctx context.Context, fn RenderFunc) error

func (*Manager) String

func (this *Manager) String() string

type RenderFunc

type RenderFunc func(context.Context, IndexerEvent) error

Jump to

Keyboard shortcuts

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