Documentation ¶
Index ¶
- Constants
- Variables
- func Contains(S []string, E string) bool
- func NewDefaultLogger(level LogLevel) *sampleLogger
- func RetryDo(retryFunc RetryFunc, stopFunc RetryShouldStopFunc, delayFunc DelayFunc, ...) error
- type BaseResponse
- type BasicAuthCredential
- type Client
- type ClientImpl
- type Config
- type Credential
- type CredentialType
- type DelayFunc
- type Domain
- type DomainPool
- type DomainResolver
- type DomainResolverFunc
- type GatewayErr
- type InternalErr
- type LogLevel
- type Logger
- type OnFailedAttemptFunc
- type RegionArea
- type ResponseInterface
- type RetryErr
- type RetryFunc
- type RetryShouldStopFunc
Constants ¶
View Source
const ( ChinaMainlandMajorDomain = "sd-rtn.com" OverseaMajorDomain = "agora.io" )
View Source
const ( US = iota EU AP CN )
View Source
const ( USWestRegionDomainPrefix = "api-us-west-1" USEastRegionDomainPrefix = "api-us-east-1" )
View Source
const ( APSoutheastRegionDomainPrefix = "api-ap-southeast-1" APNortheastRegionDomainPrefix = "api-ap-northeast-1" )
View Source
const ( EUWestRegionDomainPrefix = "api-eu-west-1" EUCentralRegionDomainPrefix = "api-eu-central-1" )
View Source
const ( CNEastRegionDomainPrefix = "api-cn-east-1" CNNorthRegionDomainPrefix = "api-cn-north-1" )
View Source
const GlobalDomainPrefix = "api"
Variables ¶
View Source
var (
DiscardLogger = &discardLogger{}
)
View Source
var RegionDomain = map[RegionArea]Domain{ US: { RegionDomainPrefixes: []string{ USWestRegionDomainPrefix, USEastRegionDomainPrefix, }, MajorDomainSuffixes: []string{ OverseaMajorDomain, ChinaMainlandMajorDomain, }, }, EU: { RegionDomainPrefixes: []string{ EUWestRegionDomainPrefix, EUCentralRegionDomainPrefix, }, MajorDomainSuffixes: []string{ OverseaMajorDomain, ChinaMainlandMajorDomain, }, }, AP: { RegionDomainPrefixes: []string{ APSoutheastRegionDomainPrefix, APNortheastRegionDomainPrefix, }, MajorDomainSuffixes: []string{ OverseaMajorDomain, ChinaMainlandMajorDomain, }, }, CN: { RegionDomainPrefixes: []string{ CNEastRegionDomainPrefix, CNNorthRegionDomainPrefix, }, MajorDomainSuffixes: []string{ ChinaMainlandMajorDomain, OverseaMajorDomain, }, }, }
Functions ¶
func NewDefaultLogger ¶
func NewDefaultLogger(level LogLevel) *sampleLogger
func RetryDo ¶
func RetryDo(retryFunc RetryFunc, stopFunc RetryShouldStopFunc, delayFunc DelayFunc, attemptFunc OnFailedAttemptFunc) error
Types ¶
type BaseResponse ¶
func (*BaseResponse) UnmarshallToTarget ¶
func (r *BaseResponse) UnmarshallToTarget(target interface{}) error
UnmarshallToTarget unmarshall body into target var successful if err is nil
type BasicAuthCredential ¶
func NewBasicAuthCredential ¶
func NewBasicAuthCredential(username string, password string) *BasicAuthCredential
func (*BasicAuthCredential) Type ¶
func (b *BasicAuthCredential) Type() CredentialType
func (*BasicAuthCredential) Visit ¶
func (b *BasicAuthCredential) Visit(r *http.Request)
type ClientImpl ¶
type ClientImpl struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(config *Config) *ClientImpl
func (*ClientImpl) DoREST ¶
func (c *ClientImpl) DoREST(ctx context.Context, path string, method string, requestBody interface{}, ) (*BaseResponse, error)
func (*ClientImpl) GetAppID ¶
func (c *ClientImpl) GetAppID() string
func (*ClientImpl) GetLogger ¶ added in v0.3.0
func (c *ClientImpl) GetLogger() Logger
type Config ¶
type Config struct { AppID string HttpTimeout time.Duration Credential Credential RegionCode RegionArea Logger Logger }
type Credential ¶
type Credential interface { Type() CredentialType Visit(r *http.Request) }
type DomainPool ¶
type DomainPool struct {
// contains filtered or unexported fields
}
func NewDomainPool ¶
func NewDomainPool(domainArea RegionArea, logger Logger) *DomainPool
func (*DomainPool) AllDomainsSuffixes ¶
func (d *DomainPool) AllDomainsSuffixes() []string
func (*DomainPool) GetCurrentRegion ¶
func (d *DomainPool) GetCurrentRegion() string
func (*DomainPool) GetCurrentUrl ¶
func (d *DomainPool) GetCurrentUrl() string
func (*DomainPool) NextRegion ¶
func (d *DomainPool) NextRegion()
func (*DomainPool) SelectBestDomain ¶
func (d *DomainPool) SelectBestDomain(ctx context.Context) error
type DomainResolver ¶
type DomainResolverFunc ¶
type GatewayErr ¶
func NewGatewayErr ¶
func NewGatewayErr(code int, msg string) *GatewayErr
func (*GatewayErr) Error ¶
func (g *GatewayErr) Error() string
type InternalErr ¶
type InternalErr struct {
Err string
}
func NewInternalErr ¶
func NewInternalErr(msg string) *InternalErr
func (*InternalErr) Error ¶
func (i *InternalErr) Error() string
type Logger ¶
type Logger interface { Debug(ctx context.Context, module string, v ...interface{}) Debugf(ctx context.Context, module string, format string, v ...interface{}) Error(ctx context.Context, module string, v ...interface{}) Errorf(ctx context.Context, module string, format string, v ...interface{}) Info(ctx context.Context, module string, v ...interface{}) Infof(ctx context.Context, module string, format string, v ...interface{}) Warn(ctx context.Context, module string, v ...interface{}) Warnf(ctx context.Context, module string, format string, v ...interface{}) Level() LogLevel SetLevel(level LogLevel) }
type OnFailedAttemptFunc ¶
type OnFailedAttemptFunc func(error)
type RegionArea ¶
type RegionArea int
type ResponseInterface ¶
type ResponseInterface interface {
IsSuccess() bool
}
type RetryErr ¶
type RetryErr struct { Err error // contains filtered or unexported fields }
func NewRetryErr ¶
type RetryShouldStopFunc ¶
type RetryShouldStopFunc func() bool
Click to show internal directories.
Click to hide internal directories.