db

package
v0.0.0-...-0127559 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer interface {
	Process(path string, doc *Document) error
	Name() string
}

Analyzer ...

type DB

type DB struct {
	Bleve bleve.Index
	Storm *storm.DB
	Queue Queue
	// contains filtered or unexported fields
}

DB database instance

func Open

func Open(path string) (*DB, error)

Open opens the database

func (*DB) AddDocumentAnalyzer

func (db *DB) AddDocumentAnalyzer(a Analyzer)

AddDocumentAnalyzer ...

func (*DB) Close

func (db *DB) Close() error

Close closes the database

func (*DB) Document

func (db *DB) Document(path string) (*Document, error)

Document returns a document for path or nil if not found

func (*DB) DocumentExists

func (db *DB) DocumentExists(path string) bool

DocumentExists is true if document already exists

func (*DB) Save

func (db *DB) Save(doc *Document) error

Save saves the doc in the DB

type Document

type Document struct {
	Path     string               `json:"path" storm:"id"`
	Analysis map[string]time.Time `json:"analysis"`
	Modified time.Time            `json:"modified"`
	Size     int64                `json:"size"`
	Fields   map[string]string    `json:"fields"`
}

Document ...

func NewDocument

func NewDocument(path string, fileInfo os.FileInfo) (*Document, error)

NewDocument ...

func (*Document) Analyze

func (d *Document) Analyze(analyzers []Analyzer) bool

Analyze performs analysis

func (Document) BleveType

func (d Document) BleveType() string

BleveType returns bleve type

func (*Document) Content

func (d *Document) Content() string

Content returns the doc content

func (*Document) GetField

func (d *Document) GetField(name string) string

GetField gets a field value or "" if no such field

func (*Document) IsImage

func (d *Document) IsImage() bool

IsImage returns true if document is an image

func (*Document) Mime

func (d *Document) Mime() string

Mime returns the mime-typeo of the doc

func (*Document) Name

func (d *Document) Name() string

Name returns the document name

func (*Document) SetContent

func (d *Document) SetContent(content string)

SetContent sets content

func (*Document) SetField

func (d *Document) SetField(name string, value string)

SetField sets document field

func (*Document) String

func (d *Document) String() string

func (*Document) Type

func (d *Document) Type() string

Type returns doc type

func (*Document) UpdateFileInfo

func (d *Document) UpdateFileInfo(fileInfo os.FileInfo)

UpdateFileInfo updates properties from file info

type Queue

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

Queue is a work queue

func (*Queue) Add

func (q *Queue) Add(path string)

Add adds item to the queue

func (*Queue) Clear

func (q *Queue) Clear()

Clear ...

func (*Queue) Len

func (q *Queue) Len() int

Len returns the number of items in the queue

func (*Queue) Pop

func (q *Queue) Pop() *string

Pop pops item from queue or nil if empty

type Worker

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

Worker db worker indexes items in the db queue.

func NewWorker

func NewWorker(db *DB) *Worker

NewWorker creates a new worker

func (*Worker) IsRunning

func (w *Worker) IsRunning() bool

IsRunning is true if worker is running

func (*Worker) Start

func (w *Worker) Start()

Start starts the worker

func (*Worker) Stop

func (w *Worker) Stop()

Stop stops the worker

Jump to

Keyboard shortcuts

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