Cancellation tokens on Create Hashed Index

This commit is contained in:
Sean Garrett
2023-06-24 18:17:55 +01:00
parent 807a4b17ce
commit 387bf6beec
6 changed files with 798 additions and 14 deletions
@@ -522,24 +522,123 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null)
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null)
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
@@ -404,6 +404,91 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
@@ -415,7 +500,23 @@ namespace MongoDbGenericRepository
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
@@ -284,10 +284,59 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
{
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
return await CreateHashedIndexAsync(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateHashedIndexAsync(field, null, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
{
return await CreateHashedIndexAsync(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateHashedIndexAsync(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
{
return await CreateHashedIndexAsync(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateHashedIndexAsync(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>
{
return await CreateHashedIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
@@ -350,6 +350,79 @@ namespace MongoDbGenericRepository
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
@@ -360,7 +433,21 @@ namespace MongoDbGenericRepository
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>