Move rate limiter ctx binding to backup operation scope

This commit is contained in:
Abhishek Pandey 2023-11-14 03:10:10 -08:00
parent 4b959098a8
commit 5bab966f67
3 changed files with 7 additions and 10 deletions

View File

@ -46,8 +46,6 @@ func (ctrl *Controller) ProduceBackupCollections(
diagnostics.Index("service", bpc.Selector.PathService().String()))
defer end()
ctx = graph.BindRateLimiterConfig(ctx, graph.LimiterCfg{Service: service})
// Limit the max number of active requests to graph from this collection.
bpc.Options.Parallelism.ItemFetch = graph.Parallelism(service).
ItemOverride(ctx, bpc.Options.Parallelism.ItemFetch)

View File

@ -589,14 +589,6 @@ func (oc *Collection) streamDriveItem(
parentPath)
ctx = clues.Add(ctx, "item_info", itemInfo)
// Drive content download requests are also rate limited by graph api.
// Ensure that this request goes through the drive limiter & not the default
// limiter.
ctx = graph.BindRateLimiterConfig(
ctx,
graph.LimiterCfg{
Service: path.OneDriveService,
})
if isFile {
dataSuffix := metadata.DataFileSuffix

View File

@ -424,6 +424,13 @@ func (op *BackupOperation) do(
lastBackupVersion = mans.MinBackupVersion()
}
// Select an appropriate rate limiter for the service.
ctx = graph.BindRateLimiterConfig(
ctx,
graph.LimiterCfg{
Service: op.Selectors.PathService(),
})
// TODO(ashmrtn): This should probably just return a collection that deletes
// the entire subtree instead of returning an additional bool. That way base
// selection is controlled completely by flags and merging is controlled