base

package
v0.0.0-...-ac046d6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Client *http.Client //HTTPClient
)

Functions

func AskFile

func AskFile(requester Request) (respStatusCode int, respBytes io.ReadCloser, respHeader http.Header, err error)

AskFile 建立http请求,返回header信息

func CalculateByteMd5

func CalculateByteMd5(b []byte) (string, error)

CalculateByteMd5 .

func CalculateFileMd5

func CalculateFileMd5(filename string) (string, error)

CalculateFileMd5 .

func CheckDownloadSignature

func CheckDownloadSignature(date, expire, bucket, objectName, signature string) bool

func CheckFileRespStatus

func CheckFileRespStatus(resp *http.Response) (io.ReadCloser, http.Header, error)

CheckFileRespStatus 状态检查

func CheckUploadSignature

func CheckUploadSignature(date, expire, signature string) bool

func CheckValid

func CheckValid(uidStr, date, expireStr string) (int64, error, string)

func DetectContentType

func DetectContentType(fileName string) (string, error)

func GenDownloadSignature

func GenDownloadSignature(uid int64, srcName, bucket, objectName, expire, date, signature string) string

func GenDownloadSingle

func GenDownloadSingle(meta models.MetaDataInfo, expire string, respChan chan models.GenDownloadResp,
	wg *sync.WaitGroup)

func GenUploadSignature

func GenUploadSignature(uid, date string, expire int, signature string) string

func GenUploadSingle

func GenUploadSingle(filename string, expire int, respChan chan models.GenUploadResp,
	metaDataInfoChan chan models.MetaDataInfo, wg *sync.WaitGroup)

GenUploadSingle .

func GetClientIp

func GetClientIp() (string, error)

GetClientIp 获取本地网卡ip

func GetExtension

func GetExtension(filename string) string

func GetOutBoundIP

func GetOutBoundIP() (string, error)

GetOutBoundIP 获取外网ip

func GetRange

func GetRange(rangeHeader string, size int64) (int64, int64)

func InTurnPrint

func InTurnPrint(filename string) string

InTurnPrint .

func InitSnowFlake

func InitSnowFlake()

InitSnowFlake .

func NewServiceRegister

func NewServiceRegister() *serviceRegister

func Query

func Query(values map[string][]string, name string) string

Types

type RedisLock

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

A RedisLock is a redis lock.

func NewRedisLock

func NewRedisLock(c *context.Context, store *redis.Client, key string) *RedisLock

NewRedisLock returns a RedisLock.

func (*RedisLock) Acquire

func (rl *RedisLock) Acquire() (bool, error)

Acquire acquires the lock. 加锁

func (*RedisLock) Release

func (rl *RedisLock) Release() (bool, error)

Release releases the lock. 释放锁

func (*RedisLock) SetExpire

func (rl *RedisLock) SetExpire(seconds int)

SetExpire sets the expire. 需要注意的是需要在Acquire()之前调用 不然默认为500ms自动释放

type Request

type Request struct {
	Url       string
	Body      io.ReadCloser
	HeaderSet map[string]string
	Method    string
	Params    map[string]string
}

type Response

type Response struct {
	Code  int             `json:"code"`
	Msg   string          `json:"message"`
	Data  json.RawMessage `json:"data"`
	Total int64           `json:"total,omitempty"`
}

func Ask

func Ask(requester Request) (respStatusCode int, respBytes *Response, respHeader http.Header, err error)

Ask 建立http请求,返回header信息

func CheckRespStatus

func CheckRespStatus(resp *http.Response) (*Response, http.Header, error)

CheckRespStatus 状态检查

type Service

type Service struct {
	IP        string
	Port      string
	CreatedAt int64
}

type Snowflake

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

func NewSnowFlake

func NewSnowFlake() *Snowflake

NewSnowFlake .

func (*Snowflake) NextId

func (sf *Snowflake) NextId() (int64, error)

NextId .

type Uid

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

Uid 每个业务独立的Uid发号器

func NewUid

func NewUid(bizId string) (*Uid, error)

NewUid 生成新的发号器

func (*Uid) NextId

func (u *Uid) NextId() (int64, error)

NextId 获取

Jump to

Keyboard shortcuts

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