model

package
v1.6.1-0...-5e9cea2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: Unlicense Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToDownloadQueue

func AppendToDownloadQueue(fileInfo *FileInfo, conf *config.Config)

func AppendToQueue

func AppendToQueue(fileInfo *FileInfo, conf *config.Config)

Read: append the file info to queen channel, the file info will send to all peers

func AutoRepair

func AutoRepair(forceRepair bool, conf *config.Config)

TODO: to check Read : AutoRepair what?

func BackUpMetaDataByDate

func BackUpMetaDataByDate(date string, conf *config.Config)

Read: BackUpMetaDataByDate back up the file 'files.md5' and 'meta.data' in the directory name with 'date'

func BenchMark

func BenchMark(ctx *gin.Context, conf *config.Config)

TODO: to check

func CheckAuth

func CheckAuth(r *http.Request, conf *config.Config) bool

CheckAuth

func CheckClusterStatus

func CheckClusterStatus(conf *config.Config)

CheckClusterStatus

func CheckDownloadAuth

func CheckDownloadAuth(ctx *gin.Context, conf *config.Config) (bool, error)

func CheckFileAndSendToPeer

func CheckFileAndSendToPeer(date string, filename string, isForceUpload bool, conf *config.Config)

func CheckFileExistByInfo

func CheckFileExistByInfo(md5s string, fileInfo *FileInfo, conf *config.Config) bool

func CheckScene

func CheckScene(scene string, conf *config.Config) (bool, error)

func CleanAndBackUp

func CleanAndBackUp(conf *config.Config)

TODO: to check

func CleanLogLevelDBByDate

func CleanLogLevelDBByDate(date string, filename string, conf *config.Config)

TODO: to check

func ConsumerDownLoad

func ConsumerDownLoad(conf *config.Config)

TODO: to check

func ConsumerPostToPeer

func ConsumerPostToPeer(conf *config.Config)

func DownloadFromPeer

func DownloadFromPeer(peer string, fileInfo *FileInfo, conf *config.Config)

func DownloadNormalFileByURI

func DownloadNormalFileByURI(ctx *gin.Context, conf *config.Config) (bool, error)

TODO: to check

func DownloadNotFound

func DownloadNotFound(ctx *gin.Context, conf *config.Config)

TODO: to check

func DownloadSmallFileByURI

func DownloadSmallFileByURI(ctx *gin.Context, conf *config.Config) (bool, error)

TODO: to check

func FormatStatInfo

func FormatStatInfo(conf *config.Config)

func GetClusterNotPermitMessage

func GetClusterNotPermitMessage(r *http.Request) string

GetClusterNotPermitMessage

func GetFileInfo

func GetFileInfo(relativePath string, router *gin.RouterGroup, conf *config.Config)

func GetFilePathByInfo

func GetFilePathByInfo(fileInfo *FileInfo, withDocker bool) string

func GetFilePathFromRequest

func GetFilePathFromRequest(reqURI string, conf *config.Config) (string, string)

GetFilePathFromRequest TODO: fix path error

func GetMd5sByDate

func GetMd5sByDate(date string, filename string, conf *config.Config) (mapSet.Set, error)

TODO: to check Read: ??

func GetMd5sMapByDate

func GetMd5sMapByDate(date string, filename string, conf *config.Config) (*pkg.CommonMap, error)

TODO: to check, no use Read: GetMd5sMapByDate use given date and file name to get md5 which will uer to create a commonMap

func GetRequestURI

func GetRequestURI(action string) string

TODO: to rm ?

func GetSmallFileByURI

func GetSmallFileByURI(ctx *gin.Context, conf *config.Config) ([]byte, bool, error)

TODO: to check GetSmallFileByURI

func HeartBeat

func HeartBeat(ctx *gin.Context)

func InitComponent

func InitComponent(isReload bool, conf *config.Config)

TODO: TO optimise initComponent init current host ip

func IsPeer

func IsPeer(r *http.Request, conf *config.Config) bool

IsPeer check the host that create the request is in the peers

func LoadFileInfoByDate

func LoadFileInfoByDate(date string, filename string, levelDB *leveldb.DB) (mapSet.Set, error)

func LoadQueueSendToPeer

func LoadQueueSendToPeer(ctx context.Context, conf *config.Config)

TODO: to check

func LoadSearchDict

func LoadSearchDict(conf *config.Config)

TODO: to check

func ParseSmallFile

func ParseSmallFile(filename string, conf *config.Config) (string, int64, int, error)

TODO: to check

func PostFileToPeer

func PostFileToPeer(fileInfo *FileInfo, conf *config.Config)

func ReceiveMd5s

func ReceiveMd5s(relativePath string, router *gin.RouterGroup, conf *config.Config)

Read: ReceiveMd5s get md5s from request, and append every one that exist in levelDB to queue channel

func RemoveDownloading

func RemoveDownloading(conf *config.Config)

TODO: to check

func RemoveKeyFromLevelDB

func RemoveKeyFromLevelDB(key string, db *leveldb.DB) error

func RepairFileInfoFromFile

func RepairFileInfoFromFile(conf *config.Config)

Read:

func RepairStatWeb

func RepairStatWeb(relativePath string, router *gin.RouterGroup, conf *config.Config)

TODO: to check

func SaveFileInfoToLevelDB

func SaveFileInfoToLevelDB(key string, fileInfo *FileInfo, db *leveldb.DB, conf *config.Config) error

func SaveFileMd5Log

func SaveFileMd5Log(fileInfo *FileInfo, md5FileName string, conf *config.Config)

TODO: to optimise

func SaveSearchDict

func SaveSearchDict(conf *config.Config)

TODO: to check

func SaveSmallFile

func SaveSmallFile(fileInfo *FileInfo, conf *config.Config) error

TODO: to check

func SaveStat

func SaveStat(conf *config.Config)

Read: SaveStat read data from statMap(which is concurrent safe map), check if the "StatisticsFileCountKey" key exists, if exists, then load all statMap data to file "stat.json"

func SendMail

func SendMail(to, subject, body, mailType string, conf *config.Config) error

func SetHttp

func SetHttp(conf *config.Config)

TODO: to check

func Stat

func Stat(relativePath string, router *gin.RouterGroup, conf *config.Config)

TODO: to check

func Status

func Status(relativePath string, router *gin.RouterGroup, conf *config.Config)

TODO: check if can be replaced with pprof

func Sync

func Sync(relativePath string, router *gin.RouterGroup, conf *config.Config)

func SyncFileInfo

func SyncFileInfo(relativePath string, router *gin.RouterGroup, conf *config.Config)

func VerifyGoogleCode

func VerifyGoogleCode(secret string, code string, discrepancy int64) bool

func WatchFilesChange

func WatchFilesChange(conf *config.Config)

TODO: to check

Types

type FileInfo

type FileInfo struct {
	Name      string   `json:"name"`
	ReName    string   `json:"rename"`
	Path      string   `json:"path"`
	Md5       string   `json:"md5"`
	Size      int64    `json:"size"`
	Peers     []string `json:"peers"`
	Scene     string   `json:"scene"`
	TimeStamp int64    `json:"timeStamp"`
	OffSet    int64    `json:"offset"`
	Retry     int
	Op        string
}

func GetFileInfoFromLevelDB

func GetFileInfoFromLevelDB(key string, conf *config.Config) (*FileInfo, error)

func SearchDict

func SearchDict(kw string, conf *config.Config) []FileInfo

TODO: no use?

type FileInfoResult

type FileInfoResult struct {
	Name    string `json:"name"`
	Md5     string `json:"md5"`
	Path    string `json:"path"`
	Size    int64  `json:"size"`
	ModTime int64  `json:"mtime"`
	IsDir   bool   `json:"is_dir"`
}

type FileLog

type FileLog struct {
	FileInfo *FileInfo
	FileName string
}

type FileResult

type FileResult struct {
	Url     string `json:"url"`
	Md5     string `json:"md5"`
	Path    string `json:"path"`
	Domain  string `json:"domain"`
	Scene   string `json:"scene"`
	Size    int64  `json:"size"`
	ModTime int64  `json:"mtime"`
	//Just for Compatibility
	Scenes  string `json:"scenes"`
	RetMsg  string `json:"retmsg"`
	RetCode int    `json:"retcode"`
	Src     string `json:"src"`
}

func BuildFileResult

func BuildFileResult(fileInfo *FileInfo, reqHost string, conf *config.Config) FileResult

type JsonResult

type JsonResult struct {
	Message string      `json:"message"`
	Status  string      `json:"status"`
	Data    interface{} `json:"data"`
}

type StatDateFileInfo

type StatDateFileInfo struct {
	Date      string `json:"date"`
	TotalSize int64  `json:"totalSize"`
	FileCount int64  `json:"fileCount"`
}

func GetStat

func GetStat(conf *config.Config) []StatDateFileInfo

func RepairStatByDate

func RepairStatByDate(date string, conf *config.Config) StatDateFileInfo

Jump to

Keyboard shortcuts

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