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