-
Notifications
You must be signed in to change notification settings - Fork 194
/
client_profile.go
62 lines (53 loc) · 1.62 KB
/
client_profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package profile
import (
"math"
"time"
)
type DurationFunc func(index int) time.Duration
func ConstantDurationFunc(duration time.Duration) DurationFunc {
return func(int) time.Duration {
return duration
}
}
func ExponentialBackoff(index int) time.Duration {
seconds := math.Pow(2, float64(index))
return time.Duration(seconds) * time.Second
}
type ClientProfile struct {
HttpProfile *HttpProfile
// Valid choices: HmacSHA1, HmacSHA256, TC3-HMAC-SHA256.
// Default value is TC3-HMAC-SHA256.
SignMethod string
UnsignedPayload bool
// Valid choices: zh-CN, en-US.
// Default value is zh-CN.
Language string
Debug bool
// define Whether to enable Regional auto switch
DisableRegionBreaker bool
// Deprecated. Use BackupEndpoint instead.
BackupEndPoint string
BackupEndpoint string
// define how to retry request
NetworkFailureMaxRetries int
NetworkFailureRetryDuration DurationFunc
RateLimitExceededMaxRetries int
RateLimitExceededRetryDuration DurationFunc
// Configure this client to retry or not when a connectivity problem is encountered.
// This differs from NetworkFailureMaxRetries that it will retry regardless of any request.
// NetworkFailureMaxRetries only retry request with field "ClientToken".
UnsafeRetryOnConnectionFailure bool
}
func NewClientProfile() *ClientProfile {
return &ClientProfile{
HttpProfile: NewHttpProfile(),
SignMethod: "TC3-HMAC-SHA256",
UnsignedPayload: false,
Language: "zh-CN",
Debug: false,
// now is true, will become to false in future
DisableRegionBreaker: true,
BackupEndPoint: "",
BackupEndpoint: "",
}
}