database

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxMongoDBVersion = semver.Version{
	Major: 3,
	Minor: 7,
	Patch: 0,
}

MaxMongoDBVersion is the upper, exclusive bound on the versions of MongoDB compatible with RITA

View Source
var MinMongoDBVersion = semver.Version{
	Major: 3,
	Minor: 2,
	Patch: 0,
}

MinMongoDBVersion is the lower, inclusive bound on the versions of MongoDB compatible with RITA

Functions

This section is empty.

Types

type DB

type DB struct {
	Session *mgo.Session
	// contains filtered or unexported fields
}

DB is the workhorse container for messing with the database

func NewDB

func NewDB(conf *config.Config, log *log.Logger) (*DB, error)

NewDB constructs a new DB struct

func (*DB) AggregateCollection

func (d *DB) AggregateCollection(sourceCollection string,
	session *mgo.Session, pipeline []bson.D) *mgo.Iter

AggregateCollection builds a collection via a MongoDB pipeline

func (*DB) CollectionExists

func (d *DB) CollectionExists(table string) bool

CollectionExists returns true if collection exists in the currently selected database

func (*DB) CreateCollection

func (d *DB) CreateCollection(name string, indeces []mgo.Index) error

CreateCollection creates a new collection in the currently selected database with the required indeces

func (*DB) GetSelectedDB

func (d *DB) GetSelectedDB() string

GetSelectedDB retrieves the currently selected database for analysis

func (*DB) MapReduceCollection

func (d *DB) MapReduceCollection(sourceCollection string, job mgo.MapReduce) bool

MapReduceCollection builds collections via javascript map reduce jobs

func (*DB) SelectDB

func (d *DB) SelectDB(db string)

SelectDB selects a database for analysis

type DBMetaInfo

type DBMetaInfo struct {
	ID             bson.ObjectId `bson:"_id,omitempty"`   // Ident
	Name           string        `bson:"name"`            // Top level name of the database
	ImportFinished bool          `bson:"import_finished"` // Has this database been entirely imported
	Analyzed       bool          `bson:"analyzed"`        // Has this database been analyzed
	ImportVersion  string        `bson:"import_version"`  // Rita version at import
	AnalyzeVersion string        `bson:"analyze_version"` // Rita version at analyze
}

DBMetaInfo defines some information about the database

type LogInfo

type LogInfo struct {
	ID      bson.ObjectId `bson:"_id,omitempty"`   // Ident
	Time    time.Time     `bson:"LastUpdateCheck"` // Top level name of the database
	Message string        `bson:"Message"`         // Top level name of the database
	Version string        `bson:"NewestVersion"`   // Top level name of the database
}

LogInfo defines information about the UpdateChecker log

type MetaDB

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

MetaDB exports control for the meta database

func NewMetaDB

func NewMetaDB(config *config.Config, dbHandle *mgo.Session,
	log *log.Logger) *MetaDB

NewMetaDB instantiates a new handle for the RITA MetaDatabase

func (*MetaDB) AddNewDB

func (m *MetaDB) AddNewDB(name string) error

AddNewDB adds a new database to the DBMetaInfo table

func (*MetaDB) AddParsedFiles

func (m *MetaDB) AddParsedFiles(files []*fpt.IndexedFile) error

AddParsedFiles adds indexed files to the files the metaDB using the bulk API

func (*MetaDB) CheckCompatibleAnalyze

func (m *MetaDB) CheckCompatibleAnalyze(targetDatabase string) (bool, error)

CheckCompatibleAnalyze checks if a database was analyzed with a version of RITA which is compatible with the running version

func (*MetaDB) CheckCompatibleImport

func (m *MetaDB) CheckCompatibleImport(targetDatabase string) (bool, error)

CheckCompatibleImport checks if a database was imported with a version of RITA which is compatible with the running version

func (*MetaDB) DeleteDB

func (m *MetaDB) DeleteDB(name string) error

DeleteDB removes a database managed by RITA

func (*MetaDB) GetAnalyzeReadyDatabases

func (m *MetaDB) GetAnalyzeReadyDatabases() []string

GetAnalyzeReadyDatabases builds a list of database names which are ready to be analyzed

func (*MetaDB) GetAnalyzedDatabases

func (m *MetaDB) GetAnalyzedDatabases() []string

GetAnalyzedDatabases builds a list of database names which have been analyzed

func (*MetaDB) GetDBMetaInfo

func (m *MetaDB) GetDBMetaInfo(name string) (DBMetaInfo, error)

GetDBMetaInfo returns a meta db entry. This is the only function which returns DBMetaInfo to code outside of meta.go.

func (*MetaDB) GetDatabases

func (m *MetaDB) GetDatabases() []string

GetDatabases returns a list of databases being tracked in metadb or an empty array on failure

func (*MetaDB) GetFiles

func (m *MetaDB) GetFiles() ([]fpt.IndexedFile, error)

GetFiles gets a list of all IndexedFile objects in the database if successful return a list of files from the database, in the case of failure return a zero length list of files and generat a log message.

func (*MetaDB) GetUnAnalyzedDatabases

func (m *MetaDB) GetUnAnalyzedDatabases() []string

GetUnAnalyzedDatabases builds a list of database names which have yet to be analyzed

func (*MetaDB) LastCheck

func (m *MetaDB) LastCheck() (time.Time, semver.Version)

LastCheck returns most recent version check

func (*MetaDB) MarkDBAnalyzed

func (m *MetaDB) MarkDBAnalyzed(name string, complete bool) error

MarkDBAnalyzed marks a database as having been analyzed

func (*MetaDB) MarkDBImported

func (m *MetaDB) MarkDBImported(name string, complete bool) error

MarkDBImported marks a database as having been completely imported

Jump to

Keyboard shortcuts

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