tencentcloud

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreResponse

func IgnoreResponse() *map[string]interface{}

IgnoreResponse return anonymous map to ignore reponse

func OnNetworkFailure

func OnNetworkFailure(ctx context.Context, act Action, request, response interface{}, err error) error

retry on temporary or timeout network failure

func OnRateLimitExceeded

func OnRateLimitExceeded(ctx context.Context, act Action, request, response interface{}, err error) error

OnRateLimitExceeded will retry on rate limit exceeded in 1s

Types

type Action

type Action struct {
	Service string
	Version string
	Action  string
}

type Client

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

func NewClient

func NewClient(opts ...Option) *Client

NewClient create Client with defaults, mutate client with Option

func (*Client) Mutate

func (c *Client) Mutate(option Option)

Mutate method mutate client properties

func (Client) Region

func (c Client) Region() string

func (*Client) Send

func (c *Client) Send(ctx context.Context, action Action, request, response interface{}) error

Send a common api request

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

http client interface, make it easy to mock

type Interceptor

type Interceptor func(ctx context.Context, action Action, request, response interface{}, err error) error

Interceptor hooks after request, like a pipeline OnNetworkFailure and OnRateLimitExceeded are default interceptors

type NeedRetry

type NeedRetry struct {
	In time.Duration
}

raise NeedRetry in interceptor will retry current request in In seconds

func (NeedRetry) Error

func (retry NeedRetry) Error() string

type Option

type Option func(*Client)

Option Used to mutate client

func WithBasicDomain added in v0.3.0

func WithBasicDomain(domain string) Option

WithBasicDomain customize basic basic domain name

func WithHttpClient

func WithHttpClient(httpClient HttpClient) Option

func WithInterceptor

func WithInterceptor(interceptor Interceptor) Option

Option to append interceptor

func WithRegion

func WithRegion(region string) Option

func WithSchema added in v0.4.3

func WithSchema(schema string) Option

func WithSecret

func WithSecret(id, key string) Option

WithSecret mutate client secret id and secret key

func WithToken added in v0.4.5

func WithToken(token string) Option

Directories

Path Synopsis
actions

Jump to

Keyboard shortcuts

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