Always GET items
This commit is contained in:
parent
93406f81a1
commit
93079b0812
@ -362,27 +362,27 @@ func downloadContent(
|
||||
itemID := ptr.Val(item.GetId())
|
||||
ctx = clues.Add(ctx, "item_id", itemID)
|
||||
|
||||
content, err := downloadItem(ctx, iaag, item)
|
||||
if err == nil {
|
||||
return content, nil
|
||||
} else if !graph.IsErrUnauthorizedOrBadToken(err) {
|
||||
return nil, err
|
||||
}
|
||||
// content, err := downloadItem(ctx, iaag, item)
|
||||
// if err == nil {
|
||||
// return content, nil
|
||||
// } else if !graph.IsErrUnauthorizedOrBadToken(err) {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// Assume unauthorized requests are a sign of an expired jwt
|
||||
// token, and that we've overrun the available window to
|
||||
// download the file. Get a fresh url from the cache and attempt to
|
||||
// download again.
|
||||
content, err = readItemContents(ctx, iaag, uc, itemID)
|
||||
if err == nil {
|
||||
logger.Ctx(ctx).Debug("found item in url cache")
|
||||
return content, nil
|
||||
}
|
||||
// // Assume unauthorized requests are a sign of an expired jwt
|
||||
// // token, and that we've overrun the available window to
|
||||
// // download the file. Get a fresh url from the cache and attempt to
|
||||
// // download again.
|
||||
// content, err = readItemContents(ctx, iaag, uc, itemID)
|
||||
// if err == nil {
|
||||
// logger.Ctx(ctx).Debug("found item in url cache")
|
||||
// return content, nil
|
||||
// }
|
||||
|
||||
// Consider cache errors(including deleted items) as cache misses.
|
||||
// Fallback to refetching the item using the graph API.
|
||||
logger.CtxErr(ctx, err).Debug("url cache miss: refetching from API")
|
||||
counter.Inc(count.URLCacheMiss)
|
||||
// // Consider cache errors(including deleted items) as cache misses.
|
||||
// // Fallback to refetching the item using the graph API.
|
||||
// logger.CtxErr(ctx, err).Debug("url cache miss: refetching from API")
|
||||
// counter.Inc(count.URLCacheMiss)
|
||||
|
||||
di, err := iaag.GetItem(ctx, driveID, ptr.Val(item.GetId()))
|
||||
if err != nil {
|
||||
@ -391,7 +391,7 @@ func downloadContent(
|
||||
|
||||
cdi := custom.ToCustomDriveItem(di)
|
||||
|
||||
content, err = downloadItem(ctx, iaag, cdi)
|
||||
content, err := downloadItem(ctx, iaag, cdi)
|
||||
if err != nil {
|
||||
return nil, clues.Wrap(err, "content download retry")
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ func KiotaHTTPClient(
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const (
|
||||
defaultDelay = 3 * time.Second
|
||||
defaultDelay = 1 * time.Second
|
||||
defaultHTTPClientTimeout = 1 * time.Hour
|
||||
defaultMaxRetries = 3
|
||||
// FIXME: This should ideally be 0, but if we set to 0, graph
|
||||
@ -291,15 +291,16 @@ func kiotaMiddlewares(
|
||||
chaosOpt := &khttp.ChaosHandlerOptions{
|
||||
ChaosStrategy: khttp.Random,
|
||||
ChaosPercentage: 50,
|
||||
StatusCode: 429,
|
||||
StatusCode: 502,
|
||||
ResponseBody: &http.Response{
|
||||
StatusCode: 429,
|
||||
Status: "Bad Gateway",
|
||||
StatusCode: 502,
|
||||
// Retry-After header
|
||||
Header: http.Header{
|
||||
"Retry-After": []string{"1"},
|
||||
},
|
||||
// Header: http.Header{
|
||||
// "Retry-After": []string{"1"},
|
||||
// },
|
||||
// Dummy body
|
||||
Body: io.NopCloser(strings.NewReader("hello")),
|
||||
Body: io.NopCloser(strings.NewReader("bad gateway, deal with it")),
|
||||
},
|
||||
}
|
||||
|
||||
@ -324,7 +325,7 @@ func kiotaMiddlewares(
|
||||
mw := []khttp.Middleware{
|
||||
msgraphgocore.NewGraphTelemetryHandler(options),
|
||||
&RetryMiddleware{
|
||||
MaxRetries: cc.maxRetries,
|
||||
MaxRetries: 9,
|
||||
Delay: cc.minDelay,
|
||||
},
|
||||
// We use default kiota retry handler for 503 and 504 errors
|
||||
@ -342,14 +343,14 @@ func kiotaMiddlewares(
|
||||
mw = append(mw, concurrencyLimitMiddlewareSingleton)
|
||||
}
|
||||
|
||||
throttler := &throttlingMiddleware{
|
||||
tf: newTimedFence(),
|
||||
counter: counter,
|
||||
}
|
||||
// throttler := &throttlingMiddleware{
|
||||
// tf: newTimedFence(),
|
||||
// counter: counter,
|
||||
// }
|
||||
|
||||
mw = append(
|
||||
mw,
|
||||
throttler,
|
||||
//throttler,
|
||||
&RateLimiterMiddleware{},
|
||||
&MetricsMiddleware{
|
||||
counter: counter,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user