diff --git a/internal/event/check_cache.go b/internal/event/check_cache.go index c201aed..05d22fe 100644 --- a/internal/event/check_cache.go +++ b/internal/event/check_cache.go @@ -9,7 +9,6 @@ import ( "gitlink.org.cn/cloudream/common/consts" "gitlink.org.cn/cloudream/common/pkg/logger" "gitlink.org.cn/cloudream/db/model" - mysql "gitlink.org.cn/cloudream/db/sql" scevt "gitlink.org.cn/cloudream/rabbitmq/message/scanner/event" ) @@ -40,7 +39,7 @@ func (t *CheckCache) Execute(execCtx ExecuteContext) { log.Debugf("begin with %v", logger.FormatStruct(t)) err := execCtx.Args.DB.DoTx(sql.LevelSerializable, func(tx *sqlx.Tx) error { - node, err := mysql.Node.GetByID(tx, t.NodeID) + node, err := execCtx.Args.DB.Node().GetByID(tx, t.NodeID) if err == sql.ErrNoRows { return nil } diff --git a/internal/event/check_rep_count.go b/internal/event/check_rep_count.go index cf6cb62..b219f1b 100644 --- a/internal/event/check_rep_count.go +++ b/internal/event/check_rep_count.go @@ -14,7 +14,6 @@ import ( "gitlink.org.cn/cloudream/scanner/internal/config" "gitlink.org.cn/cloudream/db/model" - mysql "gitlink.org.cn/cloudream/db/sql" scevt "gitlink.org.cn/cloudream/rabbitmq/message/scanner/event" ) @@ -68,12 +67,12 @@ func (t *CheckRepCount) checkOneRepCount(fileHash string, execCtx ExecuteContext var updatedNodeIDs []int err := execCtx.Args.DB.DoTx(sql.LevelSerializable, func(tx *sqlx.Tx) error { - repMaxCnt, err := mysql.ObjectRep.GetFileMaxRepCount(tx, fileHash) + repMaxCnt, err := execCtx.Args.DB.ObjectRep().GetFileMaxRepCount(tx, fileHash) if err != nil { return fmt.Errorf("get file max rep count failed, err: %w", err) } - blkCnt, err := mysql.ObjectBlock.CountBlockWithHash(tx, fileHash) + blkCnt, err := execCtx.Args.DB.ObjectBlock().CountBlockWithHash(tx, fileHash) if err != nil { return fmt.Errorf("count block with hash failed, err: %w", err) } @@ -88,7 +87,7 @@ func (t *CheckRepCount) checkOneRepCount(fileHash string, execCtx ExecuteContext return fmt.Errorf("get caching file nodes failed, err: %w", err) } - allNodes, err := mysql.Node.GetAllNodes(tx) + allNodes, err := execCtx.Args.DB.Node().GetAllNodes(tx) if err != nil { return fmt.Errorf("get all nodes failed, err: %w", err) } diff --git a/internal/tickevent/batch_all_agent_check_cache.go b/internal/tickevent/batch_all_agent_check_cache.go index 748dc50..931b999 100644 --- a/internal/tickevent/batch_all_agent_check_cache.go +++ b/internal/tickevent/batch_all_agent_check_cache.go @@ -4,7 +4,6 @@ import ( "github.com/samber/lo" "gitlink.org.cn/cloudream/common/pkg/logger" "gitlink.org.cn/cloudream/db/model" - mysql "gitlink.org.cn/cloudream/db/sql" "gitlink.org.cn/cloudream/scanner/internal/event" ) @@ -23,7 +22,7 @@ func (e *BatchAllAgentCheckCache) Execute(ctx ExecuteContext) { log.Debugf("begin") if e.nodeIDs == nil || len(e.nodeIDs) == 0 { - nodes, err := mysql.Node.GetAllNodes(ctx.Args.DB.SQLCtx()) + nodes, err := ctx.Args.DB.Node().GetAllNodes(ctx.Args.DB.SQLCtx()) if err != nil { log.Warnf("get all nodes failed, err: %s", err.Error()) return diff --git a/internal/tickevent/batch_check_all_object.go b/internal/tickevent/batch_check_all_object.go index 9d759c7..43d611b 100644 --- a/internal/tickevent/batch_check_all_object.go +++ b/internal/tickevent/batch_check_all_object.go @@ -3,7 +3,6 @@ package tickevent import ( "github.com/samber/lo" "gitlink.org.cn/cloudream/common/pkg/logger" - mysql "gitlink.org.cn/cloudream/db/sql" "gitlink.org.cn/cloudream/scanner/internal/event" ) @@ -21,7 +20,7 @@ func (e *BatchCheckAllObject) Execute(ctx ExecuteContext) { log := logger.WithType[BatchCheckAllObject]("TickEvent") log.Debugf("begin") - objectIDs, err := mysql.Object.BatchGetAllObjectIDs(ctx.Args.DB.SQLCtx(), e.lastCheckStart, CHECK_OBJECT_BATCH_SIZE) + objectIDs, err := ctx.Args.DB.Object().BatchGetAllObjectIDs(ctx.Args.DB.SQLCtx(), e.lastCheckStart, CHECK_OBJECT_BATCH_SIZE) if err != nil { log.Warnf("batch get object ids failed, err: %s", err.Error()) return diff --git a/internal/tickevent/batch_check_all_storage.go b/internal/tickevent/batch_check_all_storage.go index 1142f04..81a94da 100644 --- a/internal/tickevent/batch_check_all_storage.go +++ b/internal/tickevent/batch_check_all_storage.go @@ -2,7 +2,6 @@ package tickevent import ( "gitlink.org.cn/cloudream/common/pkg/logger" - mysql "gitlink.org.cn/cloudream/db/sql" "gitlink.org.cn/cloudream/scanner/internal/event" ) @@ -20,7 +19,7 @@ func (e *BatchCheckAllStorage) Execute(ctx ExecuteContext) { log := logger.WithType[BatchCheckAllStorage]("TickEvent") log.Debugf("begin") - storageIDs, err := mysql.Storage.BatchGetAllStorageIDs(ctx.Args.DB.SQLCtx(), e.lastCheckStart, CHECK_STORAGE_BATCH_SIZE) + storageIDs, err := ctx.Args.DB.Storage().BatchGetAllStorageIDs(ctx.Args.DB.SQLCtx(), e.lastCheckStart, CHECK_STORAGE_BATCH_SIZE) if err != nil { log.Warnf("batch get storage ids failed, err: %s", err.Error()) return diff --git a/internal/tickevent/check_agent_state.go b/internal/tickevent/check_agent_state.go index 8300a4d..9adddea 100644 --- a/internal/tickevent/check_agent_state.go +++ b/internal/tickevent/check_agent_state.go @@ -2,7 +2,6 @@ package tickevent import ( "gitlink.org.cn/cloudream/common/pkg/logger" - mysql "gitlink.org.cn/cloudream/db/sql" "gitlink.org.cn/cloudream/scanner/internal/event" ) @@ -17,7 +16,7 @@ func (e *CheckAgentState) Execute(ctx ExecuteContext) { log := logger.WithType[CheckAgentState]("TickEvent") log.Debugf("begin") - nodes, err := mysql.Node.GetAllNodes(ctx.Args.DB.SQLCtx()) + nodes, err := ctx.Args.DB.Node().GetAllNodes(ctx.Args.DB.SQLCtx()) if err != nil { log.Warnf("get all nodes failed, err: %s", err.Error()) return diff --git a/internal/tickevent/check_cache.go b/internal/tickevent/check_cache.go index 5628027..ed459da 100644 --- a/internal/tickevent/check_cache.go +++ b/internal/tickevent/check_cache.go @@ -2,7 +2,6 @@ package tickevent import ( "gitlink.org.cn/cloudream/common/pkg/logger" - mysql "gitlink.org.cn/cloudream/db/sql" "gitlink.org.cn/cloudream/scanner/internal/event" ) @@ -17,7 +16,7 @@ func (e *CheckCache) Execute(ctx ExecuteContext) { log := logger.WithType[CheckCache]("TickEvent") log.Debugf("begin") - nodes, err := mysql.Node.GetAllNodes(ctx.Args.DB.SQLCtx()) + nodes, err := ctx.Args.DB.Node().GetAllNodes(ctx.Args.DB.SQLCtx()) if err != nil { log.Warnf("get all nodes failed, err: %s", err.Error()) return