You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/vendor/github.com/qiniu/go-sdk/v7/storage/uploader_base.go

57 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package storage
import (
"github.com/qiniu/go-sdk/v7/internal/hostprovider"
"time"
)
// retryMax: 为 0使用默认值每个域名只请求一次
// hostFreezeDuration: 为 0使用默认值50ms ~ 100ms
func getUpHost(config *Config, retryMax int, hostFreezeDuration time.Duration, ak, bucket string) (upHost string, err error) {
region := config.GetRegion()
if region == nil {
if region, err = GetRegionWithOptions(ak, bucket, UCApiOptions{
RetryMax: retryMax,
HostFreezeDuration: hostFreezeDuration,
}); err != nil {
return "", err
}
}
host := region.SrcUpHosts[0]
if config.UseCdnDomains {
host = region.CdnUpHosts[0]
}
upHost = endpoint(config.UseHTTPS, host)
return
}
// retryMax: 为 0使用默认值每个域名只请求一次
// hostFreezeDuration: 为 0使用默认值50ms ~ 100ms
func getUpHostProvider(config *Config, retryMax int, hostFreezeDuration time.Duration, ak, bucket string) (hostprovider.HostProvider, error) {
region := config.GetRegion()
var err error
if region == nil {
if region, err = GetRegionWithOptions(ak, bucket, UCApiOptions{
RetryMax: retryMax,
HostFreezeDuration: hostFreezeDuration,
}); err != nil {
return nil, err
}
}
hosts := make([]string, 0, 0)
if config.UseCdnDomains && len(region.CdnUpHosts) > 0 {
hosts = append(hosts, region.CdnUpHosts...)
} else if len(region.SrcUpHosts) > 0 {
hosts = append(hosts, region.SrcUpHosts...)
}
for i := 0; i < len(hosts); i++ {
hosts[i] = endpoint(config.UseHTTPS, hosts[i])
}
return hostprovider.NewWithHosts(hosts), nil
}