Skip to content

Feature/cancellation token 2 #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

blacktau
Copy link
Contributor

@blacktau blacktau commented Jul 6, 2023

Added cancellation tokens every where. They should be mostly non-breaking changes including for mocks in unit tests.

where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
if (!documents.Any())
var documentList = documents.ToList();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did it have to be a list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous code was double enumating the enumeration which could cause issues. turning it into a list means it is enumerated once preventing issues.

{
await HandlePartitioned<TDocument, TKey>(group.FirstOrDefault()).InsertManyAsync(group.ToList(), null, cancellationToken);
}
}
else
{
await GetCollection<TDocument, TKey>().InsertManyAsync(documents.ToList(), null, cancellationToken);
await GetCollection<TDocument, TKey>().InsertManyAsync(documentsList.ToList(), null, cancellationToken);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume documentsList.ToList() is redundant now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch - has been removed

}
}
else
{
GetCollection<TDocument, TKey>().InsertMany(documents.ToList());
GetCollection<TDocument, TKey>().InsertMany(documentList.ToList(), cancellationToken: cancellationToken);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume documentsList.ToList() is redundant now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch - has been removed

@alexandre-spieser alexandre-spieser merged commit 9812bde into alexandre-spieser:master Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants