Documentation
¶
Index ¶
- Constants
- Variables
- func BackupMetaDB(backupDir string) (string, error)
- func Close(db *gorm.DB) error
- func CountAllConnections(info interface{}) (int64, error)
- func CountAllNameIDs(info interface{}) (int64, error)
- func CountConnectionsByProvider(info interface{}, providerName string) (int64, error)
- func CountNameIDsByConnection(info interface{}, connectionName string) (int64, error)
- func Delete(info interface{}, columName string, columnValue string) (bool, error)
- func DeleteBy3Conditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) (bool, error)
- func DeleteByCondition(info interface{}, columnName string, columnValue string) (bool, error)
- func DeleteByConditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) (bool, error)
- func Get(info interface{}, columnName string, columnValue string) error
- func GetBy3Conditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) error
- func GetByConditionAndContain(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) error
- func GetByConditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) error
- func GetByConditionsAndContain(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) error
- func GetByContain(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) error
- func Has(info interface{}, columnName string, columnValue string) (bool, error)
- func HasBy3Conditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) (bool, error)
- func HasByCondition(info interface{}, columnName1 string, columnValue1 string) (bool, error)
- func HasByConditions(info interface{}, columnName1 string, columnValue1 string, columnName2 string, ...) (bool, error)
- func Insert(info interface{}) error
- func List(infoList interface{}) error
- func ListByCondition(infoList interface{}, columnName string, columnValue string) error
- func ListByConditions(infoList interface{}, columnName1 string, columnValue1 string, ...) error
- func ListNameIDByConnection(info interface{}, connectionName string) ([]string, error)
- func Open() (*gorm.DB, error)
- func Ping() error
- func RotateBackups(backupDir string, maxCount int) error
- func StartBackupScheduler(ctx context.Context, cfg BackupConfig)
- type AZList
- type BackupConfig
- type KVList
Constants ¶
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
const BACKUP_FILE_PREFIX = "cb-spider_backup_"
const BACKUP_FILE_SUFFIX = ".db"
const BACKUP_TIME_FORMAT = "20060102_150405"
Variables ¶
var DB_FILE_PATH string
Functions ¶
func BackupMetaDB ¶ added in v0.12.8
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 CountAllConnections ¶ added in v0.8.17
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
CountAllNameIDs counts all name_ids using the model type passed as info
func CountConnectionsByProvider ¶ added in v0.8.17
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
CountNameIDsByConnection counts name_ids in a model filtered by connection_name
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
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 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 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
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 ListByCondition ¶
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
ListNameIDByConnection retrieves a list of name_ids in a model filtered by connection_name
func RotateBackups ¶ added in v0.12.8
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.
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.