infostore

package
v0.12.11 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_BACKUP_ENABLED   = true
	DEFAULT_BACKUP_INTERVAL  = 6 * time.Hour
	DEFAULT_BACKUP_MAX_COUNT = 10
	DEFAULT_BACKUP_DIR_NAME  = "backups"
)

Default values for backup configuration

View Source
const BACKUP_FILE_PREFIX = "cb-spider_backup_"
View Source
const BACKUP_FILE_SUFFIX = ".db"
View Source
const BACKUP_TIME_FORMAT = "20060102_150405"

Variables

View Source
var DB_FILE_PATH string

Functions

func BackupMetaDB added in v0.12.8

func BackupMetaDB(backupDir string) (string, error)

BackupMetaDB performs an online backup of the meta DB using SQLite3 VACUUM INTO. This is safe to call while the DB is being read/written by the Spider server. Returns the backup file path on success.

func Close

func Close(db *gorm.DB) error

Meta DB Closer

func CountAllConnections added in v0.8.17

func CountAllConnections(info interface{}) (int64, error)

CountAllConnections counts all entries in the connection_config_infos table info is a pointer to a ConnectionConfigInfo struct

func CountAllNameIDs added in v0.8.17

func CountAllNameIDs(info interface{}) (int64, error)

CountAllNameIDs counts all name_ids using the model type passed as info

func CountConnectionsByProvider added in v0.8.17

func CountConnectionsByProvider(info interface{}, providerName string) (int64, error)

CountConnectionsByProvider counts entries in the connection_config_infos table by provider_name info is a pointer to a ConnectionConfigInfo struct

func CountNameIDsByConnection added in v0.8.17

func CountNameIDsByConnection(info interface{}, connectionName string) (int64, error)

CountNameIDsByConnection counts name_ids in a model filtered by connection_name

func Delete

func Delete(info interface{}, columName string, columnValue string) (bool, error)

Delete a Info with a condition

func DeleteBy3Conditions

func DeleteBy3Conditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string,
	columnName3 string, columnValue3 string) (bool, error)

Delete all Infos with three conditions ex) Conneciton Name, Resource Name, Owner VPC Name

func DeleteByCondition added in v0.10.2

func DeleteByCondition(info interface{}, columnName string, columnValue string) (bool, error)

Delete Info with one condition ex) Owner VPC Name

func DeleteByConditions

func DeleteByConditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string) (bool, error)

Delete all Infos with two conditions ex) Conneciton Name, Resource Name ex) Conneciton Name, Owner VPC Name

func Get

func Get(info interface{}, columnName string, columnValue string) error

Get a Info with a condition

func GetBy3Conditions

func GetBy3Conditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string,
	columnName3 string, columnValue3 string) error

Get a Info with three conditions(Conneciton Name, Resource NameId, Owner VPC Name)

func GetByConditionAndContain added in v0.8.11

func GetByConditionAndContain(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnContainValue2 string) error

GetByConditionAndContain finds an entry that matches the given conditions: - columnName1 must equal columnValue1 - columnName2 must contain columnContainValue2

func GetByConditions

func GetByConditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string) error

Get a Info with two conditions(Conneciton Name, Resource NameId)

func GetByConditionsAndContain

func GetByConditionsAndContain(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string,
	columnName3 string, columnValue3 string) error

Get a Info with two conditions(Conneciton Name, Resource NameId) and contain(contained_text)

func GetByContain

func GetByContain(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string) error

Get a Info with a condition(Conneciton Name) and contains(contained_text)

func Has

func Has(info interface{}, columnName string, columnValue string) (bool, error)

Check if a Info exists with a condition

func HasBy3Conditions

func HasBy3Conditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string,
	columnName3 string, columnValue3 string) (bool, error)

Check if a Info exists with three conditions(Conneciton Name, Resource NameId, Owner vpc name)

func HasByCondition added in v0.10.2

func HasByCondition(info interface{}, columnName1 string, columnValue1 string) (bool, error)

Check if an Info exists with one condition (Connection Name or Resource NameId)

func HasByConditions

func HasByConditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string) (bool, error)

Check if a Info exists with two conditions(Conneciton Name, Resource NameId)

func Insert

func Insert(info interface{}) error

Insert a Info

func List

func List(infoList interface{}) error

List all Info

func ListByCondition

func ListByCondition(infoList interface{}, columnName string, columnValue string) error

List all Info with a condition(ex. Conneciton Name)

func ListByConditions

func ListByConditions(infoList interface{}, columnName1 string, columnValue1 string, columnName2 string, columnValue2 string) error

List all Info with two conditions(ex. Conneciton Name and Owner VPC Name) Used for SubnetInfoList, ...

func ListNameIDByConnection added in v0.8.20

func ListNameIDByConnection(info interface{}, connectionName string) ([]string, error)

ListNameIDByConnection retrieves a list of name_ids in a model filtered by connection_name

func Open

func Open() (*gorm.DB, error)

Meta DB Opener

func Ping added in v0.8.13

func Ping() error

func RotateBackups added in v0.12.8

func RotateBackups(backupDir string, maxCount int) error

RotateBackups enforces the maximum backup count by deleting the oldest backups. It keeps at most maxCount backup files in the backupDir.

func StartBackupScheduler added in v0.12.8

func StartBackupScheduler(ctx context.Context, cfg BackupConfig)

StartBackupScheduler starts the background meta DB backup scheduler. It performs an immediate backup on startup, then runs periodically based on cfg.Interval. The scheduler stops gracefully when the provided context is cancelled. This function is non-blocking and runs in a goroutine.

Types

type AZList added in v0.8.11

type AZList []string

AZList represents a list of availability zones. @Description A list of availability zones within a region.

func (*AZList) Scan added in v0.8.11

func (o *AZList) Scan(src any) error

func (AZList) Value added in v0.8.11

func (o AZList) Value() (driver.Value, error)

type BackupConfig added in v0.12.8

type BackupConfig struct {
	Enabled   bool          // Enable/disable backup (default: true)
	Interval  time.Duration // Backup interval (default: 6h)
	BackupDir string        // Backup directory path (default: $CBSPIDER_ROOT/meta_db/backups)
	MaxCount  int           // Maximum number of backup files to retain (default: 10)
}

BackupConfig holds configuration for the meta DB backup scheduler.

func LoadBackupConfig added in v0.12.8

func LoadBackupConfig() BackupConfig

LoadBackupConfig loads backup configuration from environment variables. If any environment variable is not set or has an invalid value, the corresponding default value is used without producing an error.

type KVList

type KVList []icdrs.KeyValue

KVList represents a list of key-value pairs. @Description A list of key-value pairs, where each entry is a key and its associated value.

func (*KVList) Scan

func (o *KVList) Scan(src any) error

func (KVList) Value

func (o KVList) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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