utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIME_FORMAT_S3  = time.RFC3339
	SUBRESOURCES_S3 = "acl,quota,storageinfo,deletebucket,delete,lifecycle,location,logging,notification,partNumber," +
		"policy,requestPayment,torrent,uploadId,uploads,versionId,versioning,versions,website"
)
View Source
const (
	V2 = "v2"
)

Variables

View Source
var DEFAULT_INITIAL_INTERVAL int64 = 50

The default initial interval.

View Source
var DEFAULT_MAX_ELAPSED_TIME int64 = 0x7fffffffffffffff

The default maximum elapsed time

View Source
var DEFAULT_MAX_INTERVAL int64 = 30000

The default maximum back off time.

View Source
var DEFAULT_MULTIPLIER float64 = 1.5

The default multiplier (increases the interval by 50%).

View Source
var STOP int64 = -1

Functions

func Decrypto

func Decrypto(result []byte, refer string) string

func Encrypto

func Encrypto(plainText []byte, refer string) []byte

func HashFileMD5

func HashFileMD5(filePath string) (string, error)

* *函数说明:文件md5加密 *入参:filePath文件全路径 *返回值:加密后的值,错误信息

func HashMD5

func HashMD5(content []byte) string

* *函数说明:字符串md5加密 *入参:content加密的字符串 *返回值:加密后的值

func ParseJson

func ParseJson(body []byte, obj interface{}) error

* *函数说明:解析json *入参:body:待解析的字符串 * obj:解析的格式,传入对象指针 *返回值:

func SetCaCertificate

func SetCaCertificate(isCrt bool, crtPath string) error

* *函数说明:设置https数字证书 *入参:isCrt 是否验证证书,false:不验证,true:验证 * crtPath 证书路径,当isCrt为true是有效 *返回值:错误信息

func SetReconnectNum

func SetReconnectNum(num uint)

* *函数说明:设置重连次数 *入参:num 重连次数 *返回值:

func SetTimeOut

func SetTimeOut(connectTime, responseTime uint)

* *函数说明:设置网络超时 *入参:second:超时时间,秒 *返回值:

Types

type ExponentialBackOff

type ExponentialBackOff struct {
	InitialInterval    int64
	Multiplier         float64
	MaxInterval        int64
	MaxElapsedTime     int64
	CurrentElapsedTime int64
	CurrentInterval    int64
}

func NewExponentialBackOff

func NewExponentialBackOff(initialInterval int64, multiplier float64, maxInterval, maxElapsedTime int64) *ExponentialBackOff

func (*ExponentialBackOff) BackOff

func (e *ExponentialBackOff) BackOff(backOff int64) int64

func (*ExponentialBackOff) GetNextBackOff

func (e *ExponentialBackOff) GetNextBackOff() int64

func (*ExponentialBackOff) ResetCurrentInterval

func (e *ExponentialBackOff) ResetCurrentInterval()

type Util

type Util struct {
	Response *http.Response
	// contains filtered or unexported fields
}

func NewUtil

func NewUtil(ak, sk, reg, auth, raw_ak, raw_sk, endpoint string, pathStyle bool) *Util

* *函数说明:初始化Util实例 *入参:AK:用户的AccessKeyID * SK:用户的SecretAccessKeyID * Region: V4鉴权使用的region * AuthType: 鉴权类型 * Endpoint:服务器地址,如(https://129.7.182.2:443) * PathStyle:请求方式是否为绝对路径方式,取值True 或 False *返回值:初始化的Util实例

func (*Util) BackupRequestBody

func (util *Util) BackupRequestBody(body []byte, sourceFile string)

* *函数说明:备份request请求消息体,重连时需要 *入参:body:请求消息体,和sourceFile不能同时存在 * sourceFile:上传的文件路径,和body不能同时存在 *返回值:获取URI值

func (*Util) Close

func (util *Util) Close()

* *函数说明:关闭http数据流 *入参: *返回值:

func (*Util) DoExec

func (util *Util) DoExec() (*http.Response, *models.Result)

* *函数说明:向服务端发送请求 *入参: *返回值:http.Response实例,Result执行结构信息

func (*Util) InitConect

func (util *Util) InitConect(mothed, projectId string, resourceMap [][]string, ioread io.Reader) error

* *函数说明:初始化连接 *入参:mothed:请求方法 * bucket:桶名 * object:对象名 * ioread:待发送的数据流 *返回值:执行失败值

func (*Util) SetHeader

func (util *Util) SetHeader(key string, value string)

* *函数说明:设置请求头域 *入参:key:head头对应key值 * value:head头的key对应值 *返回值:

func (*Util) SetPath

func (util *Util) SetPath(key, value string)

* *函数说明:设置请求URI *入参:key:uri对应key值 * value:uri的key对应值 *返回值:

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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