¸ÄÓñ¾»ú¶ÀÁ¢ CA£¬»ָ´ CLI TLS УÑ飬±£»¤ƾ¾ÝÓëÅäÖò¢·¢±£´档 д Cursor Êý¾ݡ¢»Ự·¾¶¡¢´úÀíÉúÃüÖÜÆڡ¢ģÐÍÇëÇóÓë Skills Îļþ²Ù×÷¡£ Ϊ¶ÀÁ¢ Tab ·þÎñÔö¼ӿͻ§¶˼øȨ£¬Éý¼¶ÒÀÀµÓ빤¾ßÁ´£¬ÍêÉƷ¢²¼ԪÐÅϢͬ²½¡£ Ñé֤£ºÁ½¸ö Go ģ¿éµIJâÊÔ/vet¡¢¹ؼüģ¿é race¡¢ǰ¶˲âÊÔ/Éú²ú¹¹½¨/Éó¼ơ¢ Go ¿ɴï©¶´ɨÃèÓë macOS/Linux ¿ÉÐÐģ¿齻²æ±àÒë¾ùͨ¹ý¡£ Windows ¸ôÀëÆô¶¯ͨ¹ý£»δÍê³ɵĵã»÷ðÑ̺ÍԭÉúƽ̨Ñé֤¼ûÉó²鱨¸档
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
// retry.go 保留 provider HTTP 请求入口的历史命名;provider 错误交给客户端重连链路处理。
|
||
package modeladapter
|
||
|
||
import (
|
||
"context"
|
||
"cursor/internal/netproxy"
|
||
"net/http"
|
||
)
|
||
|
||
// DoProviderRequestWithRetry 保留旧入口名;本地模式不在服务端重试 provider 请求。
|
||
func DoProviderRequestWithRetry(
|
||
ctx context.Context,
|
||
client *http.Client,
|
||
provider string,
|
||
requestID string,
|
||
modelCallID string,
|
||
buildRequest func(context.Context) (*http.Request, error),
|
||
) (*http.Response, error) {
|
||
return doProviderRequestWithRetry(ctx, client, provider, requestID, modelCallID, buildRequest)
|
||
}
|
||
|
||
func doProviderRequestWithRetry(
|
||
ctx context.Context,
|
||
client *http.Client,
|
||
provider string,
|
||
requestID string,
|
||
modelCallID string,
|
||
buildRequest func(context.Context) (*http.Request, error),
|
||
) (*http.Response, error) {
|
||
if client == nil {
|
||
client = http.DefaultClient
|
||
}
|
||
httpReq, err := buildRequest(ctx)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
resp, err := netproxy.CredentialSafeClient(client).Do(httpReq)
|
||
if err != nil {
|
||
if resp != nil && resp.Body != nil {
|
||
_ = resp.Body.Close()
|
||
}
|
||
return nil, err
|
||
}
|
||
return resp, nil
|
||
}
|
||
|
||
// ProviderRetryAttemptSummary 返回空值;provider 请求不再有服务端内部重试摘要。
|
||
func ProviderRetryAttemptSummary(resp *http.Response) string {
|
||
return ""
|
||
}
|