worker

package
v0.0.5-0...-5f39efd Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte CapacityUnit = 1
	KB                = 1024 * Byte
	MB                = 1024 * KB
	GB                = 1024 * MB
	TB                = 1024 * GB
	PB                = 1024 * TB
)
View Source
const (
	GET_FILE_ROOT_URI = "/fileRootMap"
	GET_DISK_INFO_URI = "/disk/info"
	TEST_CONNECT      = "/debug/connect"
)
View Source
const (
	COMPARE_RUNNING = "[Comparing] "
	SYNC_RUNNING    = "[Syncing] "
	VERIFY_MD5      = "[Verify MD5] "
)
View Source
const (
	URL_HRED = "http://"
)

Variables

View Source
var CapacityStrMap = make(map[string]CapacityUnit)
View Source
var DiskPartitionsCache []Partition
View Source
var DiskReadSpeedCache = make(map[string]float64)
View Source
var DiskWriteSpeedCache = make(map[string]float64)

Functions

func AddBatchSyncError

func AddBatchSyncError(absPath string, reason string, sn string)

func CancelTask

func CancelTask(busType int)

CancelTask 由外界强制设置任务终止标志

func CompareAndCacheMd5

func CompareAndCacheMd5(sf *os.File, tf *os.File) bool

func CompareMd5

func CompareMd5(sf *os.File, tf *os.File) bool

func CompareModifyTime

func CompareModifyTime(sf *os.File, tf *os.File) bool

func CreateFile

func CreateFile(bufferSize CapacityUnit, filePath string, fileSize CapacityUnit, randomContent bool) (success bool, usedTime float64)

CreateFile fileSize : KB

func CreateTimePoint

func CreateTimePoint(name string, sourcePath string, targetPath string, marks string, needLog bool)

CreateTimePoint worker对外暴露的创建时间点方法

func EstimatedTotalTime

func EstimatedTotalTime(sn string, timeCell time.Duration) time.Duration

EstimatedTotalTime 估计完成所需的时间

func FloatRound

func FloatRound(f float64, n int) float64

func GetFileMd5

func GetFileMd5(f *os.File) *string

func GetFileName

func GetFileName(path string) string

func GetFileTree

func GetFileTree(startPath string, layer int)

GetFileTree 获取文件树

func GetLocalBatchProgress

func GetLocalBatchProgress(sn string) float64

func GetNextSyncTime

func GetNextSyncTime(dayArray [7]bool, min uint8, hour uint8) time.Duration

func GetPartitionsInfo

func GetPartitionsInfo()

func GetRemoteDiskInfo

func GetRemoteDiskInfo(ip string) *[]Partition

func GetSuitableCapacityStr

func GetSuitableCapacityStr(c uint64) string

func GetTimeSum

func GetTimeSum(daySub int, hourSub int, minSub int) time.Duration

func GetTotalSize

func GetTotalSize(sn *string, startPath string, isRoot bool, lock *sync.WaitGroup)

func LoadWorkerFactory

func LoadWorkerFactory()

func LocalBatchSyncSingleTime

func LocalBatchSyncSingleTime(isPolicy bool)

LocalBatchSyncSingleTime 直接读取配置文件,无需参数

func LocalSingleSyncSingleTime

func LocalSingleSyncSingleTime(isPolicy bool)

LocalSingleSyncSingleTime 直接读取配置文件,无需参数

func NewLocalSingleWorker

func NewLocalSingleWorker(sourceFile *os.File, targetFile *os.File, sn string, md5CacheFlag bool) *common.QWorker

func NewQNQAuthReceiver

func NewQNQAuthReceiver(SN string) *common.QWorker

func NewRemoteSyncReceiver

func NewRemoteSyncReceiver(SN string) *common.QWorker

func PartitionSyncSingleTime

func PartitionSyncSingleTime()

func RemoteSingleSyncSingleTime

func RemoteSingleSyncSingleTime(localPath string, remotePath string, ip string)

func ReverseCompareAndDelete

func ReverseCompareAndDelete(sourcePath string, targetPath string)

func StartPolicySync

func StartPolicySync(duration time.Duration, notEnd *bool, isBatch bool, isRemote bool, isPartition bool, isPeriodic bool)

func TestDiskSpeed

func TestDiskSpeed(bufferSize CapacityUnit, totalSize CapacityUnit, drive string) (writeSpeed int, readSpeed int)

Types

type CapacityUnit

type CapacityUnit uint64

func ConvertCapacity

func ConvertCapacity(str string) CapacityUnit

type Disk

type Disk struct {
	Name       string
	Partitions []Partition
	MediaType  int
	Speed      uint64
}

type Partition

type Partition struct {
	Name         string  `json:"name"`
	FsType       string  `json:"fs_type"`
	TotalSizeStr string  `json:"total_size_str"`
	TotalSize    uint64  `json:"total_size"`
	FreeSizeStr  string  `json:"free_size_str"`
	FreeSize     uint64  `json:"free_size"`
	UsedPercent  float64 `json:"used_percent"`
}

type SyncFileError

type SyncFileError struct {
	AbsPath string
	Reason  string
}

func GetBatchSyncError

func GetBatchSyncError(sn string) []SyncFileError

Jump to

Keyboard shortcuts

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