packer-cn/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/conf.go

78 lines
2.5 KiB
Go
Raw Normal View History

2017-03-04 05:06:32 -05:00
package oss
import (
"time"
)
2019-10-14 10:21:52 -04:00
// HTTPTimeout defines HTTP timeout.
2017-03-04 05:06:32 -05:00
type HTTPTimeout struct {
ConnectTimeout time.Duration
ReadWriteTimeout time.Duration
HeaderTimeout time.Duration
LongTimeout time.Duration
2019-10-14 10:21:52 -04:00
IdleConnTimeout time.Duration
2017-03-04 05:06:32 -05:00
}
2019-10-14 10:21:52 -04:00
type HTTPMaxConns struct {
MaxIdleConns int
MaxIdleConnsPerHost int
}
// Config defines oss configuration
2017-03-04 05:06:32 -05:00
type Config struct {
2019-10-14 10:21:52 -04:00
Endpoint string // OSS endpoint
AccessKeyID string // AccessId
AccessKeySecret string // AccessKey
RetryTimes uint // Retry count by default it's 5.
UserAgent string // SDK name/version/system information
IsDebug bool // Enable debug mode. Default is false.
Timeout uint // Timeout in seconds. By default it's 60.
SecurityToken string // STS Token
IsCname bool // If cname is in the endpoint.
HTTPTimeout HTTPTimeout // HTTP timeout
HTTPMaxConns HTTPMaxConns // Http max connections
IsUseProxy bool // Flag of using proxy.
ProxyHost string // Flag of using proxy host.
IsAuthProxy bool // Flag of needing authentication.
ProxyUser string // Proxy user
ProxyPassword string // Proxy password
IsEnableMD5 bool // Flag of enabling MD5 for upload.
MD5Threshold int64 // Memory footprint threshold for each MD5 computation (16MB is the default), in byte. When the data is more than that, temp file is used.
IsEnableCRC bool // Flag of enabling CRC for upload.
2017-03-04 05:06:32 -05:00
}
2019-10-14 10:21:52 -04:00
// getDefaultOssConfig gets the default configuration.
2017-03-04 05:06:32 -05:00
func getDefaultOssConfig() *Config {
config := Config{}
config.Endpoint = ""
config.AccessKeyID = ""
config.AccessKeySecret = ""
config.RetryTimes = 5
config.IsDebug = false
2019-10-14 10:21:52 -04:00
config.UserAgent = userAgent()
config.Timeout = 60 // Seconds
2017-03-04 05:06:32 -05:00
config.SecurityToken = ""
config.IsCname = false
config.HTTPTimeout.ConnectTimeout = time.Second * 30 // 30s
config.HTTPTimeout.ReadWriteTimeout = time.Second * 60 // 60s
config.HTTPTimeout.HeaderTimeout = time.Second * 60 // 60s
config.HTTPTimeout.LongTimeout = time.Second * 300 // 300s
2019-10-14 10:21:52 -04:00
config.HTTPTimeout.IdleConnTimeout = time.Second * 50 // 50s
config.HTTPMaxConns.MaxIdleConns = 100
config.HTTPMaxConns.MaxIdleConnsPerHost = 100
2017-03-04 05:06:32 -05:00
config.IsUseProxy = false
config.ProxyHost = ""
config.IsAuthProxy = false
config.ProxyUser = ""
config.ProxyPassword = ""
config.MD5Threshold = 16 * 1024 * 1024 // 16MB
config.IsEnableMD5 = false
config.IsEnableCRC = true
return &config
}