You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

batch_check_all_rep_count.go 1.1 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839
  1. package tickevent
  2. import (
  3. "gitlink.org.cn/cloudream/common/pkgs/logger"
  4. "gitlink.org.cn/cloudream/storage-scanner/internal/event"
  5. )
  6. const CHECK_CACHE_BATCH_SIZE = 100
  7. type BatchCheckAllRepCount struct {
  8. lastCheckStart int
  9. }
  10. func NewBatchCheckAllRepCount() *BatchCheckAllRepCount {
  11. return &BatchCheckAllRepCount{}
  12. }
  13. func (e *BatchCheckAllRepCount) Execute(ctx ExecuteContext) {
  14. log := logger.WithType[BatchCheckAllRepCount]("TickEvent")
  15. log.Debugf("begin")
  16. defer log.Debugf("end")
  17. fileHashes, err := ctx.Args.DB.Cache().BatchGetAllFileHashes(ctx.Args.DB.SQLCtx(), e.lastCheckStart, CHECK_CACHE_BATCH_SIZE)
  18. if err != nil {
  19. log.Warnf("batch get file hashes failed, err: %s", err.Error())
  20. return
  21. }
  22. ctx.Args.EventExecutor.Post(event.NewCheckRepCount(fileHashes))
  23. // 如果结果的长度小于预期的长度,则认为已经查询了所有,下次从头再来
  24. if len(fileHashes) < CHECK_CACHE_BATCH_SIZE {
  25. e.lastCheckStart = 0
  26. log.Debugf("all rep count checked, next time will start check at 0")
  27. } else {
  28. e.lastCheckStart += CHECK_CACHE_BATCH_SIZE
  29. }
  30. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。