tea

package
v2.0.0-...-8ac445b Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultMaxAttempts sets maximum number of retries
	DefaultMaxAttempts = 3

	// DefaultMinDelay sets minimum retry delay
	DefaultMinDelay = 100 * time.Millisecond

	// DefaultMaxDelayTimeMillis sets maximum retry delay
	DefaultMaxDelay = 120 * time.Second
)

Variables

This section is empty.

Functions

func Bool

func Bool(a bool) *bool

func BoolSlice

func BoolSlice(a []bool) []*bool

func BoolSliceValue

func BoolSliceValue(a []*bool) []bool

func BoolValue

func BoolValue(a *bool) bool

func Convert

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

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

func Float32

func Float32(a float32) *float32

func Float32Slice

func Float32Slice(a []float32) []*float32

func Float32Value

func Float32Value(a *float32) float32

func Float32ValueSlice

func Float32ValueSlice(a []*float32) []float32

func Float64

func Float64(a float64) *float64

func Float64Slice

func Float64Slice(a []float64) []*float64

func Float64Value

func Float64Value(a *float64) float64

func Float64ValueSlice

func Float64ValueSlice(a []*float64) []float64

func GetBackoffDelay

func GetBackoffDelay(options *RetryOptions, ctx *RetryPolicyContext) *int64

func Int

func Int(a int) *int

func Int16

func Int16(a int16) *int16

func Int16Slice

func Int16Slice(a []int16) []*int16

func Int16Value

func Int16Value(a *int16) int16

func Int16ValueSlice

func Int16ValueSlice(a []*int16) []int16

func Int32

func Int32(a int32) *int32

func Int32Slice

func Int32Slice(a []int32) []*int32

func Int32Value

func Int32Value(a *int32) int32

func Int32ValueSlice

func Int32ValueSlice(a []*int32) []int32

func Int64

func Int64(a int64) *int64

func Int64Slice

func Int64Slice(a []int64) []*int64

func Int64Value

func Int64Value(a *int64) int64

func Int64ValueSlice

func Int64ValueSlice(a []*int64) []int64

func Int8

func Int8(a int8) *int8

func Int8Slice

func Int8Slice(a []int8) []*int8

func Int8Value

func Int8Value(a *int8) int8

func Int8ValueSlice

func Int8ValueSlice(a []*int8) []int8

func IntSlice

func IntSlice(a []int) []*int

func IntValue

func IntValue(a *int) int

func IntValueSlice

func IntValueSlice(a []*int) []int

func Merge

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

func Prettify

func Prettify(i interface{}) string

func Recover

func Recover(in interface{}) error

Recover is used to format error

func Retryable

func Retryable(err error) *bool

Deprecated

func ShouldRetry

func ShouldRetry(options *RetryOptions, ctx *RetryPolicyContext) *bool

func Sleep

func Sleep(backoffTime *int64)

func String

func String(a string) *string

func StringSlice

func StringSlice(a []string) []*string

func StringSliceValue

func StringSliceValue(a []*string) []string

func StringValue

func StringValue(a *string) string

func ToInt

func ToInt(a *int32) *int

func ToInt32

func ToInt32(a *int) *int32

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 TransInterfaceToInt64

func TransInterfaceToInt64(val interface{}) *int64

func TransInterfaceToString

func TransInterfaceToString(val interface{}) *string

func Uint

func Uint(a uint) *uint

func Uint16

func Uint16(a uint16) *uint16

func Uint16Slice

func Uint16Slice(a []uint16) []*uint16

func Uint16Value

func Uint16Value(a *uint16) uint16

func Uint16ValueSlice

func Uint16ValueSlice(a []*uint16) []uint16

func Uint32

func Uint32(a uint32) *uint32

func Uint32Slice

func Uint32Slice(a []uint32) []*uint32

func Uint32Value

func Uint32Value(a *uint32) uint32

func Uint32ValueSlice

func Uint32ValueSlice(a []*uint32) []uint32

func Uint64

func Uint64(a uint64) *uint64

func Uint64Slice

func Uint64Slice(a []uint64) []*uint64

func Uint64Value

func Uint64Value(a *uint64) uint64

func Uint64ValueSlice

func Uint64ValueSlice(a []*uint64) []uint64

func Uint8

func Uint8(a uint8) *uint8

func Uint8Slice

func Uint8Slice(a []uint8) []*uint8

func Uint8Value

func Uint8Value(a *uint8) uint8

func Uint8ValueSlice

func Uint8ValueSlice(a []*uint8) []uint8

func UintSlice

func UintSlice(a []uint) []*uint

func UintValue

func UintValue(a *uint) uint

func UintValueSlice

func UintValueSlice(a []*uint) []uint

func Validate

func Validate(params interface{}) error

Types

type BackoffPolicy

type BackoffPolicy interface {
	GetDelayTimeMillis(ctx *RetryPolicyContext) *int64
}

func NewBackoffPolicy

func NewBackoffPolicy(options map[string]interface{}) (backoffPolicy BackoffPolicy)

type BaseError

type BaseError interface {
	error
	ErrorName() *string
	ErrorCode() *string
	RetryAfterTimeMillis() *int64
}

BaseError is an interface for getting actual error

type CastError

type CastError struct {
	Message *string
	Code    *string
}

CastError is used for cast type fails

func NewCastError

func NewCastError(message *string) *CastError

NewCastError is used for cast type fails

func (*CastError) Error

func (err *CastError) Error() string

Return message of CastError

func (*CastError) ErrorCode

func (err *CastError) ErrorCode() *string

func (*CastError) ErrorName

func (err *CastError) ErrorName() *string

func (*CastError) RetryAfterTimeMillis

func (err *CastError) RetryAfterTimeMillis() *int64

type EqualJitterBackoffPolicy

type EqualJitterBackoffPolicy struct {
	Period *int
	Cap    *int64
}

func (*EqualJitterBackoffPolicy) GetDelayTimeMillis

func (equalJitterBackoff *EqualJitterBackoffPolicy) GetDelayTimeMillis(ctx *RetryPolicyContext) *int64

type ExponentialBackoffPolicy

type ExponentialBackoffPolicy struct {
	Period *int
	Cap    *int64
}

func (*ExponentialBackoffPolicy) GetDelayTimeMillis

func (exponentialBackoff *ExponentialBackoffPolicy) GetDelayTimeMillis(ctx *RetryPolicyContext) *int64

type FixedBackoffPolicy

type FixedBackoffPolicy struct {
	Period *int
}

func (*FixedBackoffPolicy) GetDelayTimeMillis

func (fixedBackoff *FixedBackoffPolicy) GetDelayTimeMillis(ctx *RetryPolicyContext) *int64

type FullJitterBackoffPolicy

type FullJitterBackoffPolicy struct {
	Period *int
	Cap    *int64
}

func (*FullJitterBackoffPolicy) GetDelayTimeMillis

func (fullJitterBackof *FullJitterBackoffPolicy) GetDelayTimeMillis(ctx *RetryPolicyContext) *int64

type RandomBackoffPolicy

type RandomBackoffPolicy struct {
	Period *int
	Cap    *int64
}

func (*RandomBackoffPolicy) GetDelayTimeMillis

func (randomBackoff *RandomBackoffPolicy) GetDelayTimeMillis(ctx *RetryPolicyContext) *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, runtimeObject *RuntimeObject) (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 RetryCondition

type RetryCondition struct {
	MaxAttempts        *int
	MaxDelayTimeMillis *int64
	Backoff            *BackoffPolicy
	Exception          []*string
	ErrorCode          []*string
}

type RetryOptions

type RetryOptions struct {
	Retryable        *bool
	RetryCondition   []*RetryCondition
	NoRetryCondition []*RetryCondition
}

type RetryPolicyContext

type RetryPolicyContext struct {
	RetriesAttempted *int
	Request          *Request
	Response         *Response
	Error            error
}

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"`
	Key            *string                `json:"key" xml:"key"`
	Cert           *string                `json:"cert" xml:"cert"`
	CA             *string                `json:"ca" xml:"ca"`
	Socks5Proxy    *string                `json:"socks5Proxy" xml:"socks5Proxy"`
	Socks5NetWork  *string                `json:"socks5NetWork" xml:"socks5NetWork"`
	Listener       utils.ProgressListener `json:"listener" xml:"listener"`
	Tracker        *utils.ReaderTracker   `json:"tracker" xml:"tracker"`
	Logger         *utils.Logger          `json:"logger" xml:"logger"`
	RetryOptions   *RetryOptions          `json:"retryOptions" xml:"retryOptions"`
}

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
	StatusCode *int
	Message    *string
	Data       *string
	Stack      *string

	Description        *string
	AccessDeniedDetail map[string]interface{}
	// contains filtered or unexported fields
}

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

func (*SDKError) ErrorCode

func (err *SDKError) ErrorCode() *string

func (*SDKError) ErrorName

func (err *SDKError) ErrorName() *string

func (*SDKError) RetryAfterTimeMillis

func (err *SDKError) RetryAfterTimeMillis() *int64

func (*SDKError) SetErrMsg

func (err *SDKError) SetErrMsg(msg string)

Set ErrMsg by msg

Jump to

Keyboard shortcuts

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