Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix storage uc host invalid #156

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82
github.com/dave/jennifer v1.6.1
github.com/elastic/go-sysinfo v1.0.2
github.com/gammazero/toposort v0.1.1
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.7.0
Expand Down
18 changes: 1 addition & 17 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ github.com/dave/jennifer v1.6.1 h1:T4T/67t6RAA5AIV6+NP8Uk/BIsXgDoqEowgycdQQLuk=
github.com/dave/jennifer v1.6.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elastic/go-sysinfo v1.0.2 h1:Wq1bOgnSz7Obl7DbMjbn0tzx1bE5G8Cfy3MVFa6C1Cc=
github.com/elastic/go-sysinfo v1.0.2/go.mod h1:O/D5m1VpYLwGjCYzEt63g3Z1uO3jXfwyzzjiW90t8cY=
github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY=
github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=
github.com/gammazero/toposort v0.1.1 h1:OivGxsWxF3U3+U80VoLJ+f50HcPU1MIqE1JlKzoJ2Eg=
github.com/gammazero/toposort v0.1.1/go.mod h1:H2cozTnNpMw0hg2VHAYsAxmkHXBYroNangj2NTBQDvw=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
Expand All @@ -31,8 +27,6 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4=
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
Expand All @@ -45,12 +39,8 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 h1:c8R11WC8m7KNMkTv/0+Be8vvwo4I3/Ut9AC2FW8fX3U=
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/qiniu/dyn v1.3.0 h1:s+xPTeV0H8yikgM4ZMBc7Rrefam8UNI3asBlkaOQg5o=
github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk=
github.com/qiniu/x v1.10.5 h1:7V/CYWEmo9axJULvrJN6sMYh2FdY+esN5h8jwDkA4b0=
Expand All @@ -59,21 +49,18 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190425145619-16072639606e h1:4ktJgTV34+N3qOZUc5fAaG3Pb11qzMm3PkAoTAgUZ2I=
golang.org/x/sys v0.0.0-20190425145619-16072639606e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand All @@ -85,12 +72,9 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
modernc.org/fileutil v1.0.0 h1:Z1AFLZwl6BO8A5NldQg/xTSjGLetp+1Ubvl4alfGx8w=
modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8=
63 changes: 39 additions & 24 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,39 +69,21 @@ func NewPersistentCache(
persistentDuration time.Duration,
handleError func(error),
) (*Cache, error) {
err := os.MkdirAll(filepath.Dir(persistentFilePath), 0700)
if err != nil {
return nil, err
}
unlockFunc, err := lockCachePersistentFile(persistentFilePath, false, handleError)
if err != nil {
return nil, err
}
defer unlockFunc()

file, closeFunc, err := openCachePersistentFile(persistentFilePath, handleError)
if err != nil {
return nil, err
}
defer closeFunc()

cacheMap, err := loadCacheMapFrom(valueType, file)
if err != nil {
return nil, err
}

return &Cache{
c := &Cache{
persistentFile: &persistentFile{
valueType: valueType,
cacheFilePath: persistentFilePath,
persistentDuration: persistentDuration,
lastPersistentTime: time.Now(),
handleError: handleError,
},
cacheMap: cacheMap,
cacheMap: nil,
compactInterval: compactInterval,
lastCompactTime: time.Now(),
}, nil
}
// 为了兼容上层接口,此处允许加载本地缓存文件失败
_ = c.loadLocalCache()
return c, nil
}

type GetResult uint8
Expand All @@ -114,6 +96,39 @@ const (
NoResultGot GetResult = 4
)

func (cache *Cache) loadLocalCache() error {
defer func() {
if cache.cacheMap == nil {
cache.cacheMap = make(map[string]cacheValue)
}
}()

persistentFilePath := cache.persistentFile.cacheFilePath
err := os.MkdirAll(filepath.Dir(persistentFilePath), 0700)
if err != nil {
return err
}
unlockFunc, err := lockCachePersistentFile(persistentFilePath, false, cache.persistentFile.handleError)
if err != nil {
return err
}
defer unlockFunc()

file, closeFunc, err := openCachePersistentFile(persistentFilePath, cache.persistentFile.handleError)
if err != nil {
return err
}
defer closeFunc()

cacheMap, err := loadCacheMapFrom(cache.persistentFile.valueType, file)
if err != nil {
return err
}

cache.cacheMap = cacheMap
return nil
}

func (cache *Cache) Get(key string, fallback func() (CacheValue, error)) (CacheValue, GetResult) {
cache.cacheMapMutex.Lock()
value, ok := cache.cacheMap[key]
Expand Down
10 changes: 1 addition & 9 deletions internal/uplog/uplog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"net/url"
"os"
"strings"
"sync"
"syscall"

sysinfo "github.com/elastic/go-sysinfo"
"github.com/qiniu/go-sdk/v7/storagev2/retrier"
)

Expand Down Expand Up @@ -63,16 +61,10 @@ const (
)

var (
osVersion string
osVersionOnce sync.Once
osVersion string
)

func getOsVersion() string {
osVersionOnce.Do(func() {
if hostInfo, err := sysinfo.Host(); err == nil {
osVersion = hostInfo.Info().KernelVersion
}
})
return osVersion
}

Expand Down
9 changes: 8 additions & 1 deletion storage/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/qiniu/go-sdk/v7/storagev2/chooser"
"github.com/qiniu/go-sdk/v7/storagev2/downloader"
"github.com/qiniu/go-sdk/v7/storagev2/http_client"
"github.com/qiniu/go-sdk/v7/storagev2/region"
"github.com/qiniu/go-sdk/v7/storagev2/resolver"
"github.com/qiniu/go-sdk/v7/storagev2/retrier"

Expand Down Expand Up @@ -376,8 +377,14 @@ func NewBucketManagerExWithOptions(mac *auth.Credentials, cfg *Config, clt *clie
cfg.CentralRsHost = DefaultRsHost
}

bucketQuery, _ := region.NewBucketRegionsQuery(getUcEndpoint(cfg.UseHTTPS, nil), &region.BucketRegionsQueryOptions{
UseInsecureProtocol: !cfg.UseHTTPS,
Client: clt.Client,
})

opts := http_client.Options{
BasicHTTPClient: clt.Client,
BucketQuery: bucketQuery,
Credentials: mac,
Interceptors: []clientv2.Interceptor{},
UseInsecureProtocol: !cfg.UseHTTPS,
Expand Down Expand Up @@ -1110,7 +1117,7 @@ func (m *BucketManager) Zone(bucket string) (z *Zone, err error) {
}

func (m *BucketManager) makeRequestOptions() *apis.Options {
return &apis.Options{OverwrittenBucketHosts: getUcEndpoint(m.Cfg.UseHTTPS, nil)}
return &apis.Options{OverwrittenBucketHosts: getUcEndpointProvider(m.Cfg.UseHTTPS, nil)}
}

// 构建op的方法,导出的方法支持在Batch操作中使用
Expand Down
2 changes: 1 addition & 1 deletion storage/bucket_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (m *BucketManager) Get(bucket, key string, options *GetObjectInput) (*GetOb
if ctx == nil {
ctx = context.Background()
}
bucketHosts, err := getUcEndpoint(m.Cfg.UseHTTPS, nil).GetEndpoints(ctx)
bucketHosts, err := getUcEndpointProvider(m.Cfg.UseHTTPS, nil).GetEndpoints(ctx)
if err != nil {
return nil, err
}
Expand Down
7 changes: 7 additions & 0 deletions storage/form_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ func NewFormUploaderEx(cfg *Config, clt *client.Client) *FormUploader {
if clt == nil {
clt = &client.DefaultClient
}

bucketQuery, _ := region.NewBucketRegionsQuery(getUcEndpoint(cfg.UseHTTPS, nil), &region.BucketRegionsQueryOptions{
UseInsecureProtocol: !cfg.UseHTTPS,
Client: clt.Client,
})

opts := http_client.Options{
BasicHTTPClient: clt.Client,
UseInsecureProtocol: !cfg.UseHTTPS,
BucketQuery: bucketQuery,
AccelerateUploading: cfg.AccelerateUploading,
HostRetryConfig: &clientv2.RetryConfig{},
}
Expand Down
17 changes: 14 additions & 3 deletions storage/pfop.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/qiniu/go-sdk/v7/internal/clientv2"
"github.com/qiniu/go-sdk/v7/media/apis"
"github.com/qiniu/go-sdk/v7/storagev2/http_client"
"github.com/qiniu/go-sdk/v7/storagev2/region"
)

// OperationManager 提供了数据处理相关的方法
Expand Down Expand Up @@ -39,8 +40,14 @@ func NewOperationManagerEx(mac *auth.Credentials, cfg *Config, clt *client.Clien
clt = &client.DefaultClient
}

bucketQuery, _ := region.NewBucketRegionsQuery(getUcEndpoint(cfg.UseHTTPS, nil), &region.BucketRegionsQueryOptions{
UseInsecureProtocol: !cfg.UseHTTPS,
Client: clt.Client,
})

opts := http_client.Options{
BasicHTTPClient: clt.Client,
BucketQuery: bucketQuery,
Credentials: mac,
Interceptors: []clientv2.Interceptor{},
UseInsecureProtocol: !cfg.UseHTTPS,
Expand Down Expand Up @@ -171,7 +178,7 @@ func (m *OperationManager) Pfop(bucket, key, fops, pipeline, notifyURL string,
NotifyUrl: notifyURL,
Force: forceNumber,
Pipeline: pipeline,
}, nil)
}, m.makeRequestOptions())
if err != nil {
return "", err
}
Expand All @@ -189,7 +196,7 @@ func (m *OperationManager) PfopV2(ctx context.Context, pfopRequest *PfopRequest)
Type: pfopRequest.Type,
Pipeline: pfopRequest.Pipeline,
WorkflowTemplateId: pfopRequest.WorkflowTemplateID,
}, nil)
}, m.makeRequestOptions())
if err != nil {
return nil, err
}
Expand All @@ -200,7 +207,7 @@ func (m *OperationManager) PfopV2(ctx context.Context, pfopRequest *PfopRequest)
func (m *OperationManager) Prefop(persistentID string) (PrefopRet, error) {
response, err := m.apiClient.Prefop(context.Background(), &apis.PrefopRequest{
PersistentId: persistentID,
}, nil)
}, m.makeRequestOptions())
if err != nil {
return PrefopRet{}, err
}
Expand Down Expand Up @@ -265,3 +272,7 @@ func (m *OperationManager) PrefopApiHost(persistentID string) (apiHost string) {
apiHost = endpoint(m.Cfg.UseHTTPS, apiHost)
return
}

func (m *OperationManager) makeRequestOptions() *apis.Options {
return &apis.Options{OverwrittenBucketHosts: getUcEndpointProvider(m.Cfg.UseHTTPS, nil)}
}
17 changes: 15 additions & 2 deletions storage/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func SetUcHosts(hosts ...string) {
ucHosts = newHosts
}

func getUcEndpoint(useHttps bool, hosts []string) region_v2.EndpointsProvider {
func getUcEndpointProvider(useHttps bool, hosts []string) region_v2.EndpointsProvider {
if len(hosts) == 0 {
if len(UcHost) > 0 {
hosts = append(hosts, endpoint(useHttps, UcHost))
Expand All @@ -284,6 +284,19 @@ func getUcEndpoint(useHttps bool, hosts []string) region_v2.EndpointsProvider {
}
}

func getUcEndpoint(useHttps bool, hosts []string) region_v2.Endpoints {
provider := getUcEndpointProvider(useHttps, hosts)
if provider == nil {
return region_v2.Endpoints{}
}

if p, ok := provider.(region_v2.Endpoints); ok {
return p
} else {
return region_v2.Endpoints{}
}
}

// GetRegion 用来根据ak和bucket来获取空间相关的机房信息
// 延用 v2, v2 结构和 v4 结构不同且暂不可替代
// Deprecated 使用 GetRegionWithOptions 替换
Expand Down Expand Up @@ -342,7 +355,7 @@ func GetRegionsInfoWithOptions(mac *auth.Credentials, options UCApiOptions) ([]R
}).GetRegions(
context.Background(),
&apis.GetRegionsRequest{Credentials: mac},
&apis.Options{OverwrittenBucketHosts: getUcEndpoint(options.UseHttps, options.Hosts)},
&apis.Options{OverwrittenBucketHosts: getUcEndpointProvider(options.UseHttps, options.Hosts)},
)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion storage/region_uc_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (options *UCApiOptions) getApiStorageClient() *apis.Storage {
}

func (options *UCApiOptions) getApiOptions() *apis.Options {
return &apis.Options{OverwrittenBucketHosts: getUcEndpoint(options.UseHttps, options.Hosts)}
return &apis.Options{OverwrittenBucketHosts: getUcEndpointProvider(options.UseHttps, options.Hosts)}
}

func DefaultUCApiOptions() UCApiOptions {
Expand Down
11 changes: 11 additions & 0 deletions storage/resume_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ func NewResumeUploaderEx(cfg *Config, clt *client.Client) *ResumeUploader {
clt = &client.DefaultClient
}

bucketQuery, _ := region.NewBucketRegionsQuery(getUcEndpoint(cfg.UseHTTPS, nil), &region.BucketRegionsQueryOptions{
UseInsecureProtocol: !cfg.UseHTTPS,
Client: clt.Client,
})

opts := http_client.Options{
BasicHTTPClient: clt.Client,
UseInsecureProtocol: !cfg.UseHTTPS,
BucketQuery: bucketQuery,
AccelerateUploading: cfg.AccelerateUploading,
HostRetryConfig: &clientv2.RetryConfig{},
}
Expand Down Expand Up @@ -257,8 +263,13 @@ type (
)

func newResumeUploaderImpl(resumeUploader *ResumeUploader, bucket, key string, hasKey bool, upToken string, upEndpoints region.EndpointsProvider, fileInfo os.FileInfo, extra *RputExtra, ret interface{}, recorderKey string) *resumeUploaderImpl {
bucketQuery, _ := region.NewBucketRegionsQuery(getUcEndpoint(resumeUploader.Cfg.UseHTTPS, nil), &region.BucketRegionsQueryOptions{
UseInsecureProtocol: !resumeUploader.Cfg.UseHTTPS,
Client: resumeUploader.Client.Client,
})
opts := http_client.Options{
BasicHTTPClient: resumeUploader.Client.Client,
BucketQuery: bucketQuery,
UseInsecureProtocol: !resumeUploader.Cfg.UseHTTPS,
AccelerateUploading: resumeUploader.Cfg.AccelerateUploading,
HostRetryConfig: &clientv2.RetryConfig{},
Expand Down
Loading
Loading