gpt4 book ai didi

go - Google Cloud Storage go客户端中的重试逻辑在哪里?

转载 作者:IT王子 更新时间:2023-10-29 02:23:56 26 4
gpt4 key购买 nike

一些谷歌 documentation对于云存储的 go 客户端说:

This library supports reading and writing large amounts of data to Cloud Storage, with internal error handling and retries, so you don't have to write your own code to do this.

但是,当使用以下将对象放入 Cloud Storage 的代码片段时,偶尔会返回 503 Service Unavailable 错误。

重试 Cloud Storage 请求的逻辑位于何处?

    conf, err := google.JWTConfigFromJSON([]byte(apiKey),storage.ScopeFullControl)

if err != nil {
panic(err)
}

ctx := cloud.NewContext(projectId, conf.Client(oauth2.NoContext))

writer := storage.NewWriter(self.ctx, Bucket, key)

_, err := writer.Write(data)
if err != nil {
return err
}

最佳答案

正如 Glenn Lewis 在 GCloud issue 上提到的那样(2 月 20 日):

We are working on a ResumableMedia upload in the google-api-go-client library that will simply retry from where it left off in case something failed during transfer. I'm hoping that this should solve the problem, but I don't have a date for you as to when this will be ready because there are continuing design discussions.

目前源代码中没有对 ResumableMedia 的引用,因此文档似乎有误。请注意,storage 包是实验性的。

关于go - Google Cloud Storage go客户端中的重试逻辑在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30769342/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com