database

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: GPL-3.0, GPL-3.0-or-later Imports: 12 Imported by: 0

Documentation

Overview

Package database contains methods used to perform CRUD operations to the MongoDB database

Package database contains methods used to perform CRUD operations to the MongoDB database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDatabase

type MongoDatabase struct {
	// Config contains the dataservice global configuration
	Config config.Configuration
	// Client contain the mongodb client
	Client *mongo.Client
	// TimeNow contains a function that return the current time
	TimeNow func() time.Time
	// Log contains logger formatted
	Log *logrus.Logger
}

MongoDatabase is a implementation

func (*MongoDatabase) ArchiveHost

func (md *MongoDatabase) ArchiveHost(hostname string) (*mongo.UpdateResult, utils.AdvancedErrorInterface)

ArchiveHost archives tho host with hostname as hostname TODO return value, not mongo struct

func (*MongoDatabase) ConnectToMongodb

func (md *MongoDatabase) ConnectToMongodb()

ConnectToMongodb connects to the MongoDB and return the connection

func (*MongoDatabase) DeleteHostData

DeleteHostData delete the hostdata

func (*MongoDatabase) FindOldArchivedHosts

func (md *MongoDatabase) FindOldArchivedHosts(t time.Time) ([]primitive.ObjectID, utils.AdvancedErrorInterface)

FindOldArchivedHosts return the list of archived hosts older than t

func (*MongoDatabase) FindOldCurrentHosts

func (md *MongoDatabase) FindOldCurrentHosts(t time.Time) ([]string, utils.AdvancedErrorInterface)

FindOldCurrentHosts return the list of current hosts that haven't sent hostdata after time t

func (*MongoDatabase) FindPatchingFunction

func (md *MongoDatabase) FindPatchingFunction(hostname string) (model.PatchingFunction, utils.AdvancedErrorInterface)

FindPatchingFunction find the the patching function associated to the hostname in the database

func (*MongoDatabase) HistoricizeOracleDbsLicenses

func (md *MongoDatabase) HistoricizeOracleDbsLicenses(licenses []dto.OracleDatabaseLicenseUsage) error

func (*MongoDatabase) Init

func (md *MongoDatabase) Init()

Init initializes the connection to the database

func (*MongoDatabase) InsertHostData

InsertHostData adds a new hostdata to the database TODO return value, not mongo struct

type MongoDatabaseInterface

type MongoDatabaseInterface interface {
	// Init initializes the connection to the database
	Init()
	// ArchiveHost archives tho host with hostname as hostname
	ArchiveHost(hostname string) (*mongo.UpdateResult, utils.AdvancedErrorInterface)
	// InsertHostData adds a new hostdata to the database
	InsertHostData(hostData model.HostDataBE) (*mongo.InsertOneResult, utils.AdvancedErrorInterface)
	// FindOldCurrentHost return the list of current hosts that haven't sent hostdata after time t
	FindOldCurrentHosts(t time.Time) ([]string, utils.AdvancedErrorInterface)
	// FindOldArchivedHosts return the list of archived hosts older than t
	FindOldArchivedHosts(t time.Time) ([]primitive.ObjectID, utils.AdvancedErrorInterface)
	// DeleteHostData delete the hostdata
	DeleteHostData(id primitive.ObjectID) utils.AdvancedErrorInterface
	// FindPatchingFunction find the the patching function associated to the hostname in the database
	FindPatchingFunction(hostname string) (model.PatchingFunction, utils.AdvancedErrorInterface)
	HistoricizeOracleDbsLicenses(licenses []dto.OracleDatabaseLicenseUsage) error
}

MongoDatabaseInterface is a interface that wrap methods used to perform CRUD operations in the mongodb database

Jump to

Keyboard shortcuts

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