GC. EventCalendarResolver Populate() refactor (#1518)
## Description Iterator Removal from Event Resolver. The iterator overhead contributes to the complexities of the GC backup pipeline. Issue 1486's goal is to remove errors that are populated from non-error scenarios (e.g. container no longer exists). - Stage 1: Reduce the number of error clauses in `Populate()` function - Stage 2: Update the M365ID retrieval process per resolver PR introduces Iterate approach used in `delta` functionality to populate the event calendar resolver. Reduces the amount of calls and variable creation during the populate function. The increase in efficiency will reduce the amount of time `concurrent` Mailbox queries are being made (application throttling). <!-- Insert PR description--> ## Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature - [x] 🐹 Trivial/Minor ## Issue(s) Related to #1486 ## Test Plan - [x] ⚡ Unit test
This commit is contained in:
parent
f938821960
commit
16e9f07d1e
@ -3,8 +3,7 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
mscal "github.com/microsoftgraph/msgraph-sdk-go/users/item/calendars"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -38,68 +37,55 @@ func (ecc *eventCalendarCache) Populate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
asyncError error
|
errs error
|
||||||
directories = make(map[string]graph.Container)
|
directories = make([]graph.Container, 0)
|
||||||
errUpdater = func(s string, e error) {
|
)
|
||||||
asyncError = support.WrapAndAppend(s, e, err)
|
|
||||||
|
builder := ecc.gs.Client().UsersById(ecc.userID).Calendars()
|
||||||
|
|
||||||
|
for {
|
||||||
|
resp, err := builder.Get(ctx, options)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, support.ConnectorStackErrorTrace(err))
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
query, err := ecc.gs.Client().UsersById(ecc.userID).Calendars().Get(ctx, options)
|
for _, cal := range resp.GetValue() {
|
||||||
if err != nil {
|
temp := CreateCalendarDisplayable(cal)
|
||||||
return errors.Wrap(err, support.ConnectorStackErrorTrace(err))
|
if err := checkIDAndName(temp); err != nil {
|
||||||
}
|
errs = support.WrapAndAppend(
|
||||||
|
"adding folder to cache",
|
||||||
|
err,
|
||||||
|
errs,
|
||||||
|
)
|
||||||
|
|
||||||
iter, err := msgraphgocore.NewPageIterator(
|
continue
|
||||||
query,
|
}
|
||||||
ecc.gs.Adapter(),
|
|
||||||
models.CreateCalendarCollectionResponseFromDiscriminatorValue,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
cb := IterativeCollectCalendarContainers(
|
directories = append(directories, temp)
|
||||||
directories,
|
}
|
||||||
"",
|
|
||||||
errUpdater,
|
|
||||||
)
|
|
||||||
|
|
||||||
iterateErr := iter.Iterate(ctx, cb)
|
if resp.GetOdataNextLink() == nil {
|
||||||
if iterateErr != nil {
|
break
|
||||||
return errors.Wrap(iterateErr, support.ConnectorStackErrorTrace(iterateErr))
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check for errors created during iteration
|
builder = mscal.NewCalendarsRequestBuilder(*resp.GetOdataNextLink(), ecc.gs.Adapter())
|
||||||
if asyncError != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, container := range directories {
|
for _, container := range directories {
|
||||||
if err := checkIDAndName(container); err != nil {
|
|
||||||
iterateErr = support.WrapAndAppend(
|
|
||||||
"adding folder to cache",
|
|
||||||
err,
|
|
||||||
iterateErr,
|
|
||||||
)
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
temp := cacheFolder{
|
temp := cacheFolder{
|
||||||
Container: container,
|
Container: container,
|
||||||
p: path.Builder{}.Append(*container.GetDisplayName()),
|
p: path.Builder{}.Append(*container.GetDisplayName()),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ecc.addFolder(temp); err != nil {
|
if err := ecc.addFolder(temp); err != nil {
|
||||||
iterateErr = support.WrapAndAppend(
|
errs = support.WrapAndAppend(
|
||||||
"failure adding "+*container.GetDisplayName(),
|
"failure adding "+*container.GetDisplayName(),
|
||||||
err,
|
err,
|
||||||
iterateErr)
|
errs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return iterateErr
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddToCache adds container to map in field 'cache'
|
// AddToCache adds container to map in field 'cache'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user