db

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDBLocked = xerrors.New("database is locked")

ErrDBLocked :

Functions

This section is empty.

Types

type DB

type DB interface {
	Name() string
	OpenDB(dbType, dbPath string, debugSQL bool, option Option) error
	CloseDB() error
	MigrateDB() error

	IsGoCPEDictModelV1() (bool, error)
	GetFetchMeta() (*models.FetchMeta, error)
	UpsertFetchMeta(*models.FetchMeta) error

	GetVendorProducts() ([]models.VendorProduct, []models.VendorProduct, error)
	GetCpesByVendorProduct(string, string) ([]string, []string, error)
	GetSimilarCpesByTitle(string, int, edlib.Algorithm) ([]models.FetchedCPE, error)
	InsertCpes(models.FetchType, models.FetchedCPEs) error
	IsDeprecated(string) (bool, error)
}

DB is interface for a database driver

func NewDB

func NewDB(dbType string, dbPath string, debugSQL bool, option Option) (driver DB, err error)

NewDB returns db driver

type Option added in v0.5.1

type Option struct {
	RedisTimeout time.Duration
}

Option :

type RDBDriver

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

RDBDriver is Driver for RDB

func (*RDBDriver) CloseDB

func (r *RDBDriver) CloseDB() (err error)

CloseDB close Database

func (*RDBDriver) GetCpesByVendorProduct

func (r *RDBDriver) GetCpesByVendorProduct(vendor, product string) ([]string, []string, error)

GetCpesByVendorProduct : GetCpesByVendorProduct

func (*RDBDriver) GetFetchMeta added in v0.4.0

func (r *RDBDriver) GetFetchMeta() (fetchMeta *models.FetchMeta, err error)

GetFetchMeta get FetchMeta from Database

func (*RDBDriver) GetSimilarCpesByTitle added in v0.5.3

func (r *RDBDriver) GetSimilarCpesByTitle(query string, n int, algorithm edlib.Algorithm) ([]models.FetchedCPE, error)

GetSimilarCpesByTitle : GetSimilarCpesByTitle

func (*RDBDriver) GetVendorProducts

func (r *RDBDriver) GetVendorProducts() ([]models.VendorProduct, []models.VendorProduct, error)

GetVendorProducts : GetVendorProducts

func (*RDBDriver) InsertCpes

func (r *RDBDriver) InsertCpes(fetchType models.FetchType, cpes models.FetchedCPEs) error

InsertCpes inserts Cpe Information into DB

func (*RDBDriver) IsDeprecated

func (r *RDBDriver) IsDeprecated(_ string) (bool, error)

IsDeprecated : IsDeprecated

func (*RDBDriver) IsGoCPEDictModelV1 added in v0.4.0

func (r *RDBDriver) IsGoCPEDictModelV1() (bool, error)

IsGoCPEDictModelV1 determines if the DB was created at the time of go-cpe-dictionary Model v1

func (*RDBDriver) MigrateDB

func (r *RDBDriver) MigrateDB() error

MigrateDB migrates Database

func (*RDBDriver) Name

func (r *RDBDriver) Name() string

Name return db name

func (*RDBDriver) OpenDB

func (r *RDBDriver) OpenDB(dbType, dbPath string, debugSQL bool, _ Option) (err error)

OpenDB opens Database

func (*RDBDriver) UpsertFetchMeta added in v0.4.0

func (r *RDBDriver) UpsertFetchMeta(fetchMeta *models.FetchMeta) error

UpsertFetchMeta upsert FetchMeta to Database

type RedisDriver

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

RedisDriver is Driver for Redis

func (*RedisDriver) CloseDB

func (r *RedisDriver) CloseDB() error

CloseDB close Database

func (*RedisDriver) GetCpesByVendorProduct

func (r *RedisDriver) GetCpesByVendorProduct(vendor, product string) ([]string, []string, error)

GetCpesByVendorProduct : GetCpesByVendorProduct

func (*RedisDriver) GetFetchMeta added in v0.4.0

func (r *RedisDriver) GetFetchMeta() (*models.FetchMeta, error)

GetFetchMeta get FetchMeta from Database

func (*RedisDriver) GetSimilarCpesByTitle added in v0.5.3

func (r *RedisDriver) GetSimilarCpesByTitle(query string, n int, algorithm edlib.Algorithm) ([]models.FetchedCPE, error)

GetSimilarCpesByTitle : GetSimilarCpesByTitle

func (*RedisDriver) GetVendorProducts

func (r *RedisDriver) GetVendorProducts() ([]models.VendorProduct, []models.VendorProduct, error)

GetVendorProducts : GetVendorProducts

func (*RedisDriver) InsertCpes

func (r *RedisDriver) InsertCpes(fetchType models.FetchType, cpes models.FetchedCPEs) (err error)

InsertCpes Select Cve information from DB.

func (*RedisDriver) IsDeprecated

func (r *RedisDriver) IsDeprecated(cpeURI string) (bool, error)

IsDeprecated : IsDeprecated

func (*RedisDriver) IsGoCPEDictModelV1 added in v0.4.0

func (r *RedisDriver) IsGoCPEDictModelV1() (bool, error)

IsGoCPEDictModelV1 determines if the DB was created at the time of go-cpe-dictionary Model v1

func (*RedisDriver) MigrateDB

func (r *RedisDriver) MigrateDB() error

MigrateDB migrates Database

func (*RedisDriver) Name

func (r *RedisDriver) Name() string

Name return db name

func (*RedisDriver) OpenDB

func (r *RedisDriver) OpenDB(_, dbPath string, _ bool, option Option) error

OpenDB opens Database

func (*RedisDriver) UpsertFetchMeta added in v0.4.0

func (r *RedisDriver) UpsertFetchMeta(fetchMeta *models.FetchMeta) error

UpsertFetchMeta upsert FetchMeta to Database

Jump to

Keyboard shortcuts

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