contract

package
v0.0.0-...-e38a99a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SuccessDesc the description of Success code
	SuccessDesc = "success"
	// FailDesc the description of Fail code
	FailDesc = "fail"
	// UnauthorizedDesc the description of Unauthorized code
	UnauthorizedDesc = "unauthorized"
	// NotFoundDesc the description of NotFound code
	NotFoundDesc = "not found"
	// NoPermissionDesc the description of NoPermission code
	NoPermissionDesc = "no permission"
	// ServerErrorDesc the description of ServerError code
	ServerErrorDesc = "server internal error"
	// AccessDenyDesc the description of AccessDeny code
	AccessDenyDesc = "access deny"
)
View Source
const (
	// FsDir is dir, see FsDirValue
	FsDir = "dir"
	// FsSize file size, bytes
	FsSize = "size"
	// FsHash file hash value
	FsHash = "hash"
	// FsCtime file create time
	FsCtime = "ctime"
	// FsAtime file last access time
	FsAtime = "atime"
	// FsMtime file last modify time
	FsMtime = "mtime"
	// FsPath file path
	FsPath = "path"
	// FsNeedHash return file hash or not
	FsNeedHash = "need_hash"
)
View Source
const (
	ParamValueTrue      = "1"
	ParamValueFalse     = "0"
	FsNeedHashValueTrue = ParamValueTrue
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiType

type ApiType int

ApiType the api type identity between client and server

const (
	// UnknownApi unknown api type
	UnknownApi ApiType = 0
	// SyncMessageApi send remote sync message api
	SyncMessageApi ApiType = 1
	// InfoApi query file server info api
	InfoApi ApiType = 2
	// AuthApi tcp server auth api
	AuthApi ApiType = 3
)

type Code

type Code int

Code the status code info

const (
	// Unknown the unknown status code
	Unknown Code = 0
	// Success the success status code
	Success Code = 1
	// Fail the standard fail status code
	Fail Code = -1
	// Unauthorized the unauthorized status code, the current user needs to sign in
	Unauthorized Code = -2
	// NotFound the resource not found status code
	NotFound Code = -3
	// NoPermission the no permission status code, the user is authorized but has no permission
	NoPermission Code = -4
	// ServerError the server error status code
	ServerError Code = -5
	// AccessDeny deny current access
	AccessDeny Code = -6
)

type Command

type Command []byte
var (
	// InfoCommand send the info command to get server info
	InfoCommand Command = []byte("info")
	// AuthCommand send the auth command with username and password to sign in the server
	AuthCommand Command = []byte("auth")
	// UnknownCommand unknown command
	UnknownCommand Command = []byte("unknown")
)

type FileInfo

type FileInfo struct {
	// Path the file path
	Path string `json:"path"`
	// IsDir is a dir the path
	IsDir FsDirValue `json:"is_dir"`
	// Size the size of path for bytes
	Size int64 `json:"size"`
	// Hash calculate the path hash value, if the path is a file
	Hash string `json:"hash"`
	// CTime create time, unix sec
	CTime int64 `json:"c_time"`
	// ATime last access time, unix sec
	ATime int64 `json:"a_time"`
	// MTime last modify time, unix sec
	MTime int64 `json:"m_time"`
}

FileInfo the basic file info description

type FileServerInfo

type FileServerInfo struct {
	Status
	// ServerAddr the server running address
	ServerAddr string `json:"server_addr"`
	// SourcePath the source base path of the file server
	SourcePath string `json:"source_path"`
	// DestPath the dest base path of the file server
	DestPath string `json:"dest_path"`
	// QueryAddr the query api address of the file server
	QueryAddr string `json:"query_addr"`
	// PushAddr the push api address of the file server
	PushAddr string `json:"push_addr"`
}

FileServerInfo the file server basic info

type FsDirValue

type FsDirValue int

FsDirValue the optional value of FsDir

const (
	// FsIsDir current path is a dir
	FsIsDir FsDirValue = 1
	// FsNotDir current path is not a dir
	FsNotDir FsDirValue = 0
	// FsUnknown current path is unknown file type
	FsUnknown FsDirValue = -1
)

func ParseFsDirValue

func ParseFsDirValue(isDir bool) FsDirValue

ParseFsDirValue parse boolean to FsDirValue

func (FsDirValue) Bool

func (v FsDirValue) Bool() bool

Bool current path is a dir or not

func (FsDirValue) Is

func (v FsDirValue) Is(t string) bool

Is is current value equal to dest

func (FsDirValue) Not

func (v FsDirValue) Not(t string) bool

Not is current value not equal to dest

func (FsDirValue) String

func (v FsDirValue) String() string

String parse the current value to string

type Message

type Message struct {
	Data []byte
}

func NewMessage

func NewMessage(data []byte) Message

func (Message) String

func (m Message) String() string

type Status

type Status struct {
	// Code current status code
	Code Code `json:"code"`
	// Message current status code description
	Message string `json:"message"`
	// ApiType mark current api type
	ApiType ApiType `json:"api_type"`
}

Status the api response status info

func FailStatus

func FailStatus(apiType ApiType) Status

FailStatus create an instance of fail status with specified api type

func NewStatus

func NewStatus(code Code, message string, apiType ApiType) Status

NewStatus create an instance of Status

func NoPermissionStatus

func NoPermissionStatus(apiType ApiType) Status

NoPermissionStatus create an instance of no permission status with specified api type

func SuccessStatus

func SuccessStatus(apiType ApiType) Status

SuccessStatus create an instance of success status with specified api type

func UnauthorizedStatus

func UnauthorizedStatus(apiType ApiType) Status

UnauthorizedStatus create an instance of unauthorized status with specified api type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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