Skip to content

Commit

Permalink
Merge pull request #39 from alexandre-spieser/alex/CancellationTokenWork
Browse files Browse the repository at this point in the history
Alex/cancellation token work
  • Loading branch information
alexandre-spieser authored Mar 15, 2021
2 parents 0e8d629 + 5f6e015 commit 71b64c8
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 171 deletions.
4 changes: 2 additions & 2 deletions CoreIntegrationTests/CoreIntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.2" />
<PackageReference Include="MongoDB.Driver" Version="2.9.3" />
<PackageReference Include="MongoDbGenericRepository" Version="1.4.5" />
<PackageReference Include="MongoDB.Driver" Version="2.12.0" />
<PackageReference Include="MongoDbGenericRepository" Version="1.4.6" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ public async Task GetMinValueAsync()

#region Index Management

static SemaphoreSlim textIndexSemaphore = new SemaphoreSlim(1, 1);
static readonly SemaphoreSlim textIndexSemaphore = new SemaphoreSlim(1, 1);

[Fact]
public async Task CreateTextIndexNoOptionAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace MongoDbGenericRepository
{
/// <summary>
/// The IBaseMongoRepository_Update interface exposing update functionality for documents with Guid Ids.
/// </summary>
public interface IBaseMongoRepository_Update : IBaseMongoRepository_Update<Guid>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@

namespace MongoDbGenericRepository.DataAccess.Update
{
/// <summary>
/// The IBaseMongoRepository_Update_ClientSession interface exposing update functionality with a IClientSessionHandle.
/// </summary>
public interface IBaseMongoRepository_Update_ClientSession
{
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand All @@ -27,10 +34,14 @@ public interface IBaseMongoRepository_Update_ClientSession
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand All @@ -40,11 +51,13 @@ public interface IBaseMongoRepository_Update_ClientSession
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand All @@ -55,10 +68,9 @@ public interface IBaseMongoRepository_Update_ClientSession
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand All @@ -68,13 +80,11 @@ public interface IBaseMongoRepository_Update_ClientSession
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand All @@ -86,11 +96,12 @@ public interface IBaseMongoRepository_Update_ClientSession
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand Down Expand Up @@ -118,13 +129,12 @@ public interface IBaseMongoRepository_Update_ClientSession
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand All @@ -134,14 +144,10 @@ public interface IBaseMongoRepository_Update_ClientSession
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand All @@ -151,14 +157,11 @@ public interface IBaseMongoRepository_Update_ClientSession
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
Expand Down
Loading

0 comments on commit 71b64c8

Please sign in to comment.