Thread contexts through some GC functions (#728)
## Description Will be used later and just generally useful if we ever add tracing or such to these functions. ## Type of change Please check the type of change your PR introduces: - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [x] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> #456 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
4a96f2571d
commit
ae28971be3
@ -1,6 +1,7 @@
|
|||||||
package exchange
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
@ -75,6 +76,7 @@ func loadService(t *testing.T) *exchangeService {
|
|||||||
// functions are valid for current versioning of msgraph-go-sdk
|
// functions are valid for current versioning of msgraph-go-sdk
|
||||||
func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
|
func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
|
||||||
var (
|
var (
|
||||||
|
ctx = context.Background()
|
||||||
t = suite.T()
|
t = suite.T()
|
||||||
mailScope, contactScope selectors.ExchangeScope
|
mailScope, contactScope selectors.ExchangeScope
|
||||||
userID = tester.M365UserID(t)
|
userID = tester.M365UserID(t)
|
||||||
@ -141,6 +143,7 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
|
|||||||
// callbackFunc iterates through all models.Messageable and fills exchange.Collection.jobs[]
|
// callbackFunc iterates through all models.Messageable and fills exchange.Collection.jobs[]
|
||||||
// with corresponding item IDs. New collections are created for each directory
|
// with corresponding item IDs. New collections are created for each directory
|
||||||
callbackFunc := test.iterativeFunction(
|
callbackFunc := test.iterativeFunction(
|
||||||
|
ctx,
|
||||||
userID,
|
userID,
|
||||||
test.scope,
|
test.scope,
|
||||||
errs, false,
|
errs, false,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package exchange
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
@ -29,6 +30,7 @@ type displayable interface {
|
|||||||
// GraphIterateFuncs are iterate functions to be used with the M365 iterators (e.g. msgraphgocore.NewPageIterator)
|
// GraphIterateFuncs are iterate functions to be used with the M365 iterators (e.g. msgraphgocore.NewPageIterator)
|
||||||
// @returns a callback func that works with msgraphgocore.PageIterator.Iterate function
|
// @returns a callback func that works with msgraphgocore.PageIterator.Iterate function
|
||||||
type GraphIterateFunc func(
|
type GraphIterateFunc func(
|
||||||
|
ctx context.Context,
|
||||||
user string,
|
user string,
|
||||||
scope selectors.ExchangeScope,
|
scope selectors.ExchangeScope,
|
||||||
errs error,
|
errs error,
|
||||||
@ -43,6 +45,7 @@ type GraphIterateFunc func(
|
|||||||
// objects belonging to any folder are
|
// objects belonging to any folder are
|
||||||
// placed into a Collection based on the parent folder
|
// placed into a Collection based on the parent folder
|
||||||
func IterateSelectAllDescendablesForCollections(
|
func IterateSelectAllDescendablesForCollections(
|
||||||
|
ctx context.Context,
|
||||||
user string,
|
user string,
|
||||||
scope selectors.ExchangeScope,
|
scope selectors.ExchangeScope,
|
||||||
errs error,
|
errs error,
|
||||||
@ -108,6 +111,7 @@ func IterateSelectAllDescendablesForCollections(
|
|||||||
// and storing events in collections based on
|
// and storing events in collections based on
|
||||||
// the calendarID which originates from M365.
|
// the calendarID which originates from M365.
|
||||||
func IterateSelectAllEventsForCollections(
|
func IterateSelectAllEventsForCollections(
|
||||||
|
ctx context.Context,
|
||||||
user string,
|
user string,
|
||||||
scope selectors.ExchangeScope,
|
scope selectors.ExchangeScope,
|
||||||
errs error,
|
errs error,
|
||||||
@ -191,6 +195,7 @@ func IterateSelectAllEventsForCollections(
|
|||||||
// that places exchange mail message ids belonging to specific directories
|
// that places exchange mail message ids belonging to specific directories
|
||||||
// into a Collection. Messages outside of those directories are omitted.
|
// into a Collection. Messages outside of those directories are omitted.
|
||||||
func IterateAndFilterMessagesForCollections(
|
func IterateAndFilterMessagesForCollections(
|
||||||
|
ctx context.Context,
|
||||||
user string,
|
user string,
|
||||||
scope selectors.ExchangeScope,
|
scope selectors.ExchangeScope,
|
||||||
errs error,
|
errs error,
|
||||||
@ -204,6 +209,7 @@ func IterateAndFilterMessagesForCollections(
|
|||||||
return func(messageItem any) bool {
|
return func(messageItem any) bool {
|
||||||
if !isFilterSet {
|
if !isFilterSet {
|
||||||
err := CollectMailFolders(
|
err := CollectMailFolders(
|
||||||
|
ctx,
|
||||||
scope,
|
scope,
|
||||||
user,
|
user,
|
||||||
collections,
|
collections,
|
||||||
@ -237,6 +243,7 @@ func IterateAndFilterMessagesForCollections(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IterateFilterFolderDirectoriesForCollections(
|
func IterateFilterFolderDirectoriesForCollections(
|
||||||
|
ctx context.Context,
|
||||||
user string,
|
user string,
|
||||||
scope selectors.ExchangeScope,
|
scope selectors.ExchangeScope,
|
||||||
errs error,
|
errs error,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package exchange
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
@ -124,6 +125,7 @@ func RetrieveMessageDataForUser(gs graph.Service, user, m365ID string) (absser.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CollectMailFolders(
|
func CollectMailFolders(
|
||||||
|
ctx context.Context,
|
||||||
scope selectors.ExchangeScope,
|
scope selectors.ExchangeScope,
|
||||||
user string,
|
user string,
|
||||||
collections map[string]*Collection,
|
collections map[string]*Collection,
|
||||||
@ -155,6 +157,7 @@ func CollectMailFolders(
|
|||||||
}
|
}
|
||||||
|
|
||||||
callbackFunc := IterateFilterFolderDirectoriesForCollections(
|
callbackFunc := IterateFilterFolderDirectoriesForCollections(
|
||||||
|
ctx,
|
||||||
user,
|
user,
|
||||||
scope,
|
scope,
|
||||||
err,
|
err,
|
||||||
|
|||||||
@ -350,7 +350,7 @@ func (gc *GraphConnector) createCollections(
|
|||||||
// callbackFunc iterates through all M365 object target and fills exchange.Collection.jobs[]
|
// callbackFunc iterates through all M365 object target and fills exchange.Collection.jobs[]
|
||||||
// with corresponding item M365IDs. New collections are created for each directory.
|
// with corresponding item M365IDs. New collections are created for each directory.
|
||||||
// Each directory used the M365 Identifier. The use of ID stops collisions betweens users
|
// Each directory used the M365 Identifier. The use of ID stops collisions betweens users
|
||||||
callbackFunc := gIter(user, scope, errs, gc.failFast, gc.credentials, collections, gc.statusCh)
|
callbackFunc := gIter(ctx, user, scope, errs, gc.failFast, gc.credentials, collections, gc.statusCh)
|
||||||
iterateError := pageIterator.Iterate(callbackFunc)
|
iterateError := pageIterator.Iterate(callbackFunc)
|
||||||
|
|
||||||
if iterateError != nil {
|
if iterateError != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user