@@ -6,12 +6,10 @@ import (
6
6
"fmt"
7
7
"net/http"
8
8
"net/url"
9
- "time"
10
9
11
10
"github.com/AgoraIO-Community/agora-rest-client-go/agora"
12
11
"github.com/AgoraIO-Community/agora-rest-client-go/agora/client"
13
12
"github.com/AgoraIO-Community/agora-rest-client-go/agora/log"
14
- "github.com/AgoraIO-Community/agora-rest-client-go/agora/retry"
15
13
"github.com/AgoraIO-Community/agora-rest-client-go/services/convoai/req"
16
14
"github.com/AgoraIO-Community/agora-rest-client-go/services/convoai/resp"
17
15
)
@@ -86,7 +84,7 @@ func buildQueryFields(options ...req.ListOption) map[string]any {
86
84
func (q * List ) Do (ctx context.Context , options ... req.ListOption ) (* resp.ListResp , error ) {
87
85
queryFields := buildQueryFields (options ... )
88
86
path := q .buildPath (queryFields )
89
- responseData , err := q .doRESTWithRetry (ctx , path , http .MethodGet , nil )
87
+ responseData , err := q .client . DoREST (ctx , path , http .MethodGet , nil )
90
88
if err != nil {
91
89
var internalErr * agora.InternalErr
92
90
if ! errors .As (err , & internalErr ) {
@@ -114,51 +112,3 @@ func (q *List) Do(ctx context.Context, options ...req.ListOption) (*resp.ListRes
114
112
115
113
return & listResp , nil
116
114
}
117
-
118
- const listRetryCount = 3
119
-
120
- func (q * List ) doRESTWithRetry (ctx context.Context , path string , method string , requestBody interface {}) (* agora.BaseResponse , error ) {
121
- var (
122
- baseResponse * agora.BaseResponse
123
- err error
124
- retryCount int
125
- )
126
-
127
- err = retry .Do (func (retryCount int ) error {
128
- var doErr error
129
-
130
- baseResponse , doErr = q .client .DoREST (ctx , path , method , requestBody )
131
- if doErr != nil {
132
- return agora .NewRetryErr (false , doErr )
133
- }
134
-
135
- statusCode := baseResponse .HttpStatusCode
136
- switch {
137
- case statusCode == 200 || statusCode == 201 :
138
- return nil
139
- case statusCode >= 400 && statusCode < 499 :
140
- q .logger .Debugf (ctx , q .module , "http status code is %d, no retry,http response:%s" , statusCode , baseResponse .RawBody )
141
- return agora .NewRetryErr (
142
- false ,
143
- agora .NewInternalErr (fmt .Sprintf ("http status code is %d, no retry,http response:%s" , statusCode , baseResponse .RawBody )),
144
- )
145
- default :
146
- q .logger .Debugf (ctx , q .module , "http status code is %d, retry,http response:%s" , statusCode , baseResponse .RawBody )
147
- return fmt .Errorf ("http status code is %d, retry" , baseResponse .RawBody )
148
- }
149
- }, func () bool {
150
- select {
151
- case <- ctx .Done ():
152
- return true
153
- default :
154
- }
155
- return retryCount >= listRetryCount
156
- }, func (i int ) time.Duration {
157
- return time .Second * time .Duration (i + 1 )
158
- }, func (err error ) {
159
- q .logger .Debugf (ctx , q .module , "http request err:%s" , err )
160
- retryCount ++
161
- })
162
-
163
- return baseResponse , err
164
- }
0 commit comments