dbcore

package
v0.1.46 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SystemVersionKey = "system_version"

SystemVersionKey 是记录“上次启动所用版本标识”的配置键(存于 configs 表)。 取代旧的 ./data/.komari-version 文件:版本标识随配置库一起备份/恢复, 也避免额外的裸文件依赖。

Variables

This section is empty.

Functions

func Close

func Close() error

Close 关闭底层数据库连接,供关闭流程调用。

func GetDBInstance

func GetDBInstance() *gorm.DB

GetDBInstance 返回全局数据库实例。 为兼容既有大量调用点,这里保留“出错即退出”的语义; 需要错误处理的启动流程应优先调用 Initialize()。

func Initialize

func Initialize() error

Initialize 显式初始化数据库连接与表结构,仅执行一次。 与 GetDBInstance 不同,Initialize 返回错误而非直接退出进程, 便于启动生命周期统一处理错误、以及在测试/CLI 命令中做隔离。

func ReadyDBInstance added in v0.1.9

func ReadyDBInstance() *gorm.DB

ReadyDBInstance 返回已经初始化好的数据库句柄;尚未初始化时返回 nil。

与 GetDBInstance 的区别是它【不会触发初始化】,因此也不会在初始化失败时 Fatalf。 给「数据库不可用也不该让功能失败」的可选数据用 —— 解锁探测结果就是这类:它由节点 单独上报,ip-info 的单元测试不建库,用 GetDBInstance 会让整个测试进程直接退出。

func ReclaimSpace

func ReclaimSpace(ctx context.Context) error

ReclaimSpace checkpoints the main database WAL and rewrites the SQLite file.

func SetVersionID

func SetVersionID(id string)

SetVersionID 设置当前构建的版本标识(通常为 CurrentVersion+"-"+VersionHash), 用于版本升级检测与自动备份。应在 Initialize() 之前调用;为空则跳过升级备份。

func StorageSize

func StorageSize() (int64, error)

StorageSize returns the bytes occupied by the main SQLite database and its WAL/SHM sidecar files.

Types

This section is empty.

Jump to

Keyboard shortcuts

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