tea

package
v2.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowRetry

func AllowRetry(retry interface{}, retryTimes int) bool

func AssertContains

func AssertContains(t *testing.T, contains string, msgAndArgs ...string)

func AssertEqual

func AssertEqual(t *testing.T, a, b interface{})

func AssertNil

func AssertNil(t *testing.T, object interface{})

func AssertNotNil

func AssertNotNil(t *testing.T, object interface{})

func Convert

func Convert(in interface{}, out interface{}) error

Convert is use convert map[string]interface object to struct

func GetBackoffTime

func GetBackoffTime(backoff interface{}, retrytimes int) int

func InitLogMsg

func InitLogMsg(fieldMap map[string]string)

func Merge

func Merge(args ...interface{}) map[string]string

func NewCastError

func NewCastError(message string) (err error)

NewCastError is used for cast type fails

func Prettify

func Prettify(i interface{}) string

func PublishProgress

func PublishProgress(listener ProgressListener, event *ProgressEvent)

publishProgress

func Retryable

func Retryable(err error) bool

func SetLogChannel

func SetLogChannel(channel string)

func Sleep

func Sleep(backoffTime int)

func ToMap

func ToMap(args ...interface{}) map[string]interface{}

func ToObject

func ToObject(obj interface{}) map[string]interface{}

func ToReader

func ToReader(obj interface{}) io.Reader

func ToString

func ToString(val interface{}) string

func TransInterfaceToBool

func TransInterfaceToBool(val interface{}) bool

func TransInterfaceToInt

func TransInterfaceToInt(val interface{}) int

func TransInterfaceToString

func TransInterfaceToString(val interface{}) string

func TransToString

func TransToString(object interface{}) string

func Validate

func Validate(params interface{}) error

Types

type CastError

type CastError struct {
	Message string
}

CastError is used for cast type fails

func (*CastError) Error

func (err *CastError) Error() string

Return message of CastError

type Debug

type Debug func(format string, v ...interface{})

func Init

func Init(flag string) Debug

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(level string, channel string, out io.Writer, template string) *Logger

func (*Logger) CloseLogger

func (logger *Logger) CloseLogger()

func (*Logger) GetFormatTemplate

func (logger *Logger) GetFormatTemplate() string

func (*Logger) GetIsopen

func (logger *Logger) GetIsopen() bool

func (*Logger) GetLastLogMsg

func (logger *Logger) GetLastLogMsg() string

func (*Logger) OpenLogger

func (logger *Logger) OpenLogger()

func (*Logger) PrintLog

func (logger *Logger) PrintLog(fieldMap map[string]string, err error)

func (*Logger) SetFormatTemplate

func (logger *Logger) SetFormatTemplate(template string)

func (*Logger) SetIsopen

func (logger *Logger) SetIsopen(isopen bool)

func (*Logger) SetLastLogMsg

func (logger *Logger) SetLastLogMsg(lastLogMsg string)

type ProgressEvent

type ProgressEvent struct {
	ConsumedBytes int64
	TotalBytes    int64
	RwBytes       int64
	EventType     ProgressEventType
}

ProgressEvent defines progress event

func NewProgressEvent

func NewProgressEvent(eventType ProgressEventType, consumed, total int64, rwBytes int64) *ProgressEvent

type ProgressEventType

type ProgressEventType int

ProgressEventType defines transfer progress event type

const (
	// TransferStartedEvent transfer started, set TotalBytes
	TransferStartedEvent ProgressEventType = 1 + iota
	// TransferDataEvent transfer data, set ConsumedBytes anmd TotalBytes
	TransferDataEvent
	// TransferCompletedEvent transfer completed
	TransferCompletedEvent
	// TransferFailedEvent transfer encounters an error
	TransferFailedEvent
)

type ProgressListener

type ProgressListener interface {
	ProgressChanged(event *ProgressEvent)
}

ProgressListener listens progress change

func GetProgressListener

func GetProgressListener(obj interface{}) ProgressListener

type ReaderTracker

type ReaderTracker struct {
	CompletedBytes int64
}

type Request

type Request struct {
	Protocol string
	Port     int
	Method   string
	Pathname string
	Domain   string
	Headers  map[string]string
	Query    map[string]string
	Body     io.Reader
}

Request is used wrap http request

func NewRequest

func NewRequest() (req *Request)

NewRequest is used shortly create Request

type Response

type Response struct {
	Body          io.ReadCloser
	StatusCode    int
	StatusMessage string
	Headers       map[string]string
}

Response is use d wrap http response

func DoRequest

func DoRequest(request *Request, requestRuntime map[string]interface{}) (response *Response, err error)

DoRequest is used send request to server

func NewResponse

func NewResponse(httpResponse *http.Response) (res *Response)

NewResponse is create response with http response

func (*Response) ReadBody

func (response *Response) ReadBody() (body []byte, err error)

ReadBody is used read response body

type RuntimeObject

type RuntimeObject struct {
	IgnoreSSL      bool             `json:"ignoreSSL" xml:"ignoreSSL"`
	ReadTimeout    int              `json:"readTimeout" xml:"readTimeout"`
	ConnectTimeout int              `json:"connectTimeout" xml:"connectTimeout"`
	LocalAddr      string           `json:"localAddr" xml:"localAddr"`
	HttpProxy      string           `json:"httpProxy" xml:"httpProxy"`
	HttpsProxy     string           `json:"httpsProxy" xml:"httpsProxy"`
	NoProxy        string           `json:"noProxy" xml:"noProxy"`
	MaxIdleConns   int              `json:"maxIdleConns" xml:"maxIdleConns"`
	Socks5Proxy    string           `json:"socks5Proxy" xml:"socks5Proxy"`
	Socks5NetWork  string           `json:"socks5NetWork" xml:"socks5NetWork"`
	Listener       ProgressListener `json:"listener" xml:"listener"`
	Tracker        *ReaderTracker   `json:"tracker" xml:"tracker"`
	Logger         *Logger          `json:"logger" xml:"logger"`
}

RuntimeObject is used for converting http configuration

func NewRuntimeObject

func NewRuntimeObject(runtime map[string]interface{}) *RuntimeObject

NewRuntimeObject is used for shortly create runtime object

type SDKError

type SDKError struct {
	Code    string
	Message string
	Data    string
}

SDKError struct is used save error code and message

func NewSDKError

func NewSDKError(obj map[string]interface{}) *SDKError

NewSDKError is used for shortly create SDKError object

func (*SDKError) Error

func (err *SDKError) Error() string

Jump to

Keyboard shortcuts

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