en

package
v0.0.0-...-dbb8d9c Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: Unlicense Imports: 15 Imported by: 0

Documentation

Overview

业务实体结构定义 (文件数据结构, 文件操作日志结构)

HTTP 响应数据结构定义

服务端接口定义

存储对象

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultServer

type DefaultServer struct {
	// contains filtered or unexported fields
}

服务端实现 ---------- ---------- name 服务器唯一名称 group 访问路由-分组(路由名称) ---------- ----------

func NewServer

func NewServer(name, group string) *DefaultServer

初始化服务端

func (DefaultServer) GetGroupRouteName

func (s DefaultServer) GetGroupRouteName() string

获取访问路由名称, 未配置使用服务名称

func (DefaultServer) GetServerName

func (s DefaultServer) GetServerName() string

获取服务名称

type FileInfo

type FileInfo struct {
	Name      string   `json:"name"`      // 文件名称(上传的文件名称)
	ReName    string   `json:"rename"`    // 文件完整信息名称(主要信息组成), 命名保存文件的名称
	Path      string   `json:"path"`      // 文件路径
	Md5       string   `json:"md5"`       // 文件标识 (文件(路径)Hash)
	Size      int64    `json:"size"`      // 文件大小
	Peers     []string `json:"peers"`     // 文件存在的集群节点
	Scene     string   `json:"scene"`     // 文件场景
	TimeStamp int64    `json:"timeStamp"` // 文件时间戳
	OffSet    int64    `json:"offset"`    // -1 上传后新建的文件 , -2 文件变更后的文件 | >= 0 small file | 文件偏移, 小文件合并时, 包含文件数的偏移 , 值大于等于0
	Retry     int      // 重试次数计数器 (文件下载)
	Op        string   // 操作描述, 用于描述监视过程中发生的事件类型
}

文件结构定义 ---------- ---------- ----------

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 FileUploadResult

type FileUploadResult struct {
	Url     string `json:"url"`    // 下载地址
	Md5     string `json:"md5"`    // 文件标识
	Path    string `json:"path"`   // 文件路径 (下载路径)
	Src     string `json:"src"`    // 文件路径 (存储路径)
	Domain  string `json:"domain"` // 下载域, 配置的下载地址或者获取本节点地址
	Scene   string `json:"scene"`  // 文件场景
	Size    int64  `json:"size"`   // 文件大小
	ModTime int64  `json:"mtime"`  // 文件时间戳
	Scenes  string `json:"scenes"`
	Retmsg  string `json:"retmsg"`
	Retcode int    `json:"retcode"`
}

文件上传成功, 结果返回文件实体结构定义

type HookDataStore

type HookDataStore struct {
	tusd.DataStore
}

存储对象

func (HookDataStore) NewUpload

func (store HookDataStore) NewUpload(info tusd.FileInfo) (id string, err error)

上传文件

type HttpError

type HttpError struct {
	// contains filtered or unexported fields
}

HTTP 异常状态

func (HttpError) Body

func (err HttpError) Body() []byte

HTTP 异常描述

func (HttpError) StatusCode

func (err HttpError) StatusCode() int

HTTP 异常编码

type JsonResult

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

HTTP 返回结果

type Server

type Server interface {
	GetServerName() string     // 获取服务名称
	GetGroupRouteName() string // 获取访问路由名称, 未配置使用服务名称
	GetHost() string
	GetLdb() *leveldb.DB
	GetStatMap() *goutil.CommonMap
	GetSceneMap() *goutil.CommonMap
	GetSumMap() *goutil.CommonMap
	GetQueueUpload() chan WrapReqResp
	GetQueueFromPeers() chan FileInfo
	GetQueueToPeers() chan FileInfo
	GetQueueFileLog() chan *FileLog

	// 重新加载后台服务
	Reload(w http.ResponseWriter, r *http.Request)

	//
	AppendToQueue(fileInfo *FileInfo)
	AppendToDownloadQueue(fileInfo *FileInfo)

	// 上传文件
	Upload(w http.ResponseWriter, r *http.Request)

	// 文件下载
	DownloadFromPeer(peer string, fileInfo *FileInfo)                               // 从集群(查找到文件的节点 peer)中下载文件
	NotPermit(w http.ResponseWriter, r *http.Request)                               // 返回 401 , 没有访问权限
	CheckAuth(w http.ResponseWriter, r *http.Request) bool                          //
	CheckPeerFileExist(peer string, md5sum string, fpath string) (*FileInfo, error) // 检测文件是否存在, 并获取文件信息
	GetFileInfoFromLevelDB(key string) (*FileInfo, error)                           // 从数据库中查询文件
	VerifyGoogleCode(secret string, code string, discrepancy int64) bool

	RemoveKeyFromLevelDB(key string, db *leveldb.DB) error                                   // 从数据库删除文件信息
	SaveFileInfoToLevelDB(key string, fileInfo *FileInfo, db *leveldb.DB) (*FileInfo, error) // 保存文件信息到数据库
	SaveFileMd5Log(fileInfo *FileInfo, filename string)                                      // 保存文件日志信息数据
	CheckFileAndSendToPeer(date string, filename string, isForceUpload bool)
	//
	AutoRepair(forceRepair bool)
	RepairStatByDate(date string) StatDateFileInfo
	RepairFileInfoFromFile()
	BackUpMetaDataByDate(date string)

	GetRequestURI(action string) string
	GetMd5sByDate(date string, filename string) (mapset.Set, error)
}

服务端定义

type StatDateFileInfo

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

状态文件内容结构定义 [统计(按日期)文件数量和大小]

type WrapReqResp

type WrapReqResp struct {
	W    *http.ResponseWriter
	R    *http.Request
	Done chan bool
}

HTTP 请求处理实体 [文件上传队列]

Jump to

Keyboard shortcuts

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