Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
modabas authored Jul 8, 2023
2 parents 689179a + ea3372c commit e8a8133
Show file tree
Hide file tree
Showing 179 changed files with 396 additions and 366 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Orleans.Clustering.DynamoDB
internal class DynamoDBGatewayListProvider : IGatewayListProvider
{
private DynamoDBStorage storage;
private string clusterId;
private readonly string clusterId;
private readonly string INSTANCE_STATUS_ACTIVE = ((int)SiloStatus.Active).ToString();
private readonly ILogger logger;
private readonly DynamoDBGatewayOptions options;
Expand Down
2 changes: 1 addition & 1 deletion src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class SQSStorage
private const string AccessKeyPropertyName = "AccessKey";
private const string SecretKeyPropertyName = "SecretKey";
private const string ServicePropertyName = "Service";
private ILogger Logger;
private readonly ILogger Logger;
private string accessKey;
private string secretKey;
private string service;
Expand Down
4 changes: 2 additions & 2 deletions src/AWS/Orleans.Streaming.SQS/Streams/SQSAdapterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class SQSAdapterFactory : IQueueAdapterFactory
private readonly ClusterOptions clusterOptions;
private readonly Serializer<SQSBatchContainer> serializer;
private readonly ILoggerFactory loggerFactory;
private HashRingBasedStreamQueueMapper streamQueueMapper;
private IQueueAdapterCache adapterCache;
private readonly HashRingBasedStreamQueueMapper streamQueueMapper;
private readonly IQueueAdapterCache adapterCache;

/// <summary>
/// Application level failure handler override.
Expand Down
10 changes: 5 additions & 5 deletions src/AWS/Shared/Storage/DynamoDBStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace Orleans.Transactions.DynamoDB
/// </summary>
internal class DynamoDBStorage
{
private string accessKey;
private string token;
private string profileName;
private readonly string accessKey;
private readonly string token;
private readonly string profileName;
/// <summary> Secret key for this dynamoDB table </summary>
protected string secretKey;
private string service;
private readonly string service;
public const int DefaultReadCapacityUnits = 10;
public const int DefaultWriteCapacityUnits = 5;
private readonly ProvisionedThroughput provisionedThroughput;
Expand All @@ -47,7 +47,7 @@ internal class DynamoDBStorage
TableStatus.CREATING, TableStatus.UPDATING, TableStatus.ACTIVE
});
private AmazonDynamoDBClient ddbClient;
private ILogger Logger;
private readonly ILogger Logger;

/// <summary>
/// Create a DynamoDBStorage instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Orleans.Runtime.MembershipService
{
public class AdoNetClusteringTable : IMembershipTable
{
private string clusterId;
private readonly string clusterId;
private readonly IServiceProvider serviceProvider;
private ILogger logger;
private readonly ILogger logger;
private RelationalOrleansQueries orleansQueries;
private readonly AdoNetClusteringSiloOptions clusteringTableOptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Orleans.Runtime.Membership
public class AdoNetGatewayListProvider : IGatewayListProvider
{
private readonly ILogger logger;
private string clusterId;
private readonly string clusterId;
private readonly AdoNetClusteringClientOptions options;
private RelationalOrleansQueries orleansQueries;
private readonly IServiceProvider serviceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public async Task ClearStateAsync<T>(string grainType, GrainId grainReference, I
command.AddParameter("GrainIdExtensionString", grainId.StringKey);
command.AddParameter("ServiceId", serviceId);
command.AddParameter("GrainStateVersion", !string.IsNullOrWhiteSpace(grainState.ETag) ? int.Parse(grainState.ETag, CultureInfo.InvariantCulture) : default(int?));
}, (selector, resultSetCount, token) => Task.FromResult(selector.GetValue(0).ToString()), CancellationToken.None).ConfigureAwait(false));
}, (selector, resultSetCount, token) => Task.FromResult(selector.GetValue(0).ToString()), cancellationToken: CancellationToken.None).ConfigureAwait(false));
storageVersion = clearRecord.SingleOrDefault();
}
catch(Exception ex)
Expand Down Expand Up @@ -282,7 +282,7 @@ public async Task ReadStateAsync<T>(string grainType, GrainId grainReference, IG
var result = Tuple.Create(storageState, version?.ToString(CultureInfo.InvariantCulture));
return Task.FromResult(result);
},
CancellationToken.None, commandBehavior).ConfigureAwait(false)).SingleOrDefault();
commandBehavior, CancellationToken.None).ConfigureAwait(false)).SingleOrDefault();

T state = readRecords != null ? (T) readRecords.Item1 : default;
string etag = readRecords != null ? readRecords.Item2 : null;
Expand Down Expand Up @@ -371,7 +371,7 @@ public async Task WriteStateAsync<T>(string grainType, GrainId grainReference, I
command.AddParameter("GrainStateVersion", !string.IsNullOrWhiteSpace(grainState.ETag) ? int.Parse(grainState.ETag, CultureInfo.InvariantCulture) : default(int?));
command.AddParameter("PayloadBinary", serialized.ToArray());
}, (selector, resultSetCount, token) =>
{ return Task.FromResult(selector.GetNullableInt32("NewGrainStateVersion").ToString()); }, CancellationToken.None).ConfigureAwait(false);
{ return Task.FromResult(selector.GetNullableInt32("NewGrainStateVersion").ToString()); }, cancellationToken: CancellationToken.None).ConfigureAwait(false);
storageVersion = writeRecord.SingleOrDefault();
}
catch(Exception ex)
Expand Down
18 changes: 9 additions & 9 deletions src/AdoNet/Shared/Storage/IRelationalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ internal interface IRelationalStorage
/// <param name="query">The query to execute.</param>
/// <param name="parameterProvider">Adds parameters to the query. The parameters must be in the same order with same names as defined in the query.</param>
/// <param name="selector">This function transforms the raw <see cref="IDataRecord"/> results to type <see paramref="TResult"/> the <see cref="int"/> parameter being the resultset number.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <param name="commandBehavior">The command behavior that should be used. Defaults to <see cref="CommandBehavior.Default"/>.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <returns>A list of objects as a result of the <see paramref="query"/>.</returns>
/// <example>This sample shows how to make a hand-tuned database call.
/// <code>
Expand All @@ -58,7 +58,7 @@ internal interface IRelationalStorage
/// tp1.DbType = DbType.String;
/// tp1.Direction = ParameterDirection.Input;
/// command.Parameters.Add(tp1);
///
///
/// //The selector is used to select the results within the result set. In this case there are two homogenous
/// //result sets, so there is actually no need to check which result set the selector holds and it could
/// //marked with by convention by underscore (_).
Expand All @@ -70,19 +70,19 @@ internal interface IRelationalStorage
/// {
/// TABLE_CATALOG = selector.GetValueOrDefault&lt;string&gt;("TABLE_CATALOG"),
/// TABLE_NAME = selector.GetValueOrDefault&lt;string&gt;("TABLE_NAME")
/// }
///}).ConfigureAwait(continueOnCapturedContext: false);
/// </code>
/// }
///}).ConfigureAwait(continueOnCapturedContext: false);
/// </code>
/// </example>
Task<IEnumerable<TResult>> ReadAsync<TResult>(string query, Action<IDbCommand> parameterProvider, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default(CancellationToken), CommandBehavior commandBehavior = CommandBehavior.Default);
Task<IEnumerable<TResult>> ReadAsync<TResult>(string query, Action<IDbCommand> parameterProvider, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CommandBehavior commandBehavior = CommandBehavior.Default, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Executes a given statement. Especially intended to use with <em>INSERT</em>, <em>UPDATE</em>, <em>DELETE</em> or <em>DDL</em> queries.
/// </summary>
/// <param name="query">The query to execute.</param>
/// <param name="parameterProvider">Adds parameters to the query. Parameter names must match those defined in the query.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <param name="commandBehavior">The command behavior that should be used. Defaults to <see cref="CommandBehavior.Default"/>.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <returns>Affected rows count.</returns>
/// <example>This sample shows how to make a hand-tuned database call.
/// <code>
Expand All @@ -94,10 +94,10 @@ internal interface IRelationalStorage
/// //There aren't parameters here, but they'd be added like when reading.
/// //As the affected rows count is the only thing returned, there isn't
/// //facilities to read anything.
/// }).ConfigureAwait(continueOnCapturedContext: false);
/// }).ConfigureAwait(continueOnCapturedContext: false);
/// </code>
/// </example>
Task<int> ExecuteAsync(string query, Action<IDbCommand> parameterProvider, CancellationToken cancellationToken = default(CancellationToken), CommandBehavior commandBehavior = CommandBehavior.Default);
Task<int> ExecuteAsync(string query, Action<IDbCommand> parameterProvider, CommandBehavior commandBehavior = CommandBehavior.Default, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// The well known invariant name of the underlying database.
Expand Down
38 changes: 19 additions & 19 deletions src/AdoNet/Shared/Storage/RelationalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Orleans.Tests.SqlUtils
{
/// <summary>
/// A general purpose class to work with a given relational database and ADO.NET provider.
/// </summary>
/// </summary>
[DebuggerDisplay("InvariantName = {InvariantName}, ConnectionString = {ConnectionString}")]
internal class RelationalStorage: IRelationalStorage
{
Expand Down Expand Up @@ -103,11 +103,11 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
/// Executes a given statement. Especially intended to use with <em>SELECT</em> statement.
/// </summary>
/// <typeparam name="TResult">The result type.</typeparam>
/// <param name="query">Executes a given statement. Especially intended to use with <em>SELECT</em> statement.</param>
/// <param name="query">Executes a given statement. Especially intended to use with <em>SELECT</em> statement.</param>
/// <param name="parameterProvider">Adds parameters to the query. Parameter names must match those defined in the query.</param>
/// <param name="selector">This function transforms the raw <see cref="IDataRecord"/> results to type <see paramref="TResult"/> the <see cref="int"/> parameter being the resultset number.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <param name="commandBehavior">The command behavior that should be used. Defaults to <see cref="CommandBehavior.Default"/>.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <returns>A list of objects as a result of the <see paramref="query"/>.</returns>
/// <example>This sample shows how to make a hand-tuned database call.
/// <code>
Expand All @@ -132,7 +132,7 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
/// tp1.DbType = DbType.String;
/// tp1.Direction = ParameterDirection.Input;
/// command.Parameters.Add(tp1);
///
///
/// //The selector is used to select the results within the result set. In this case there are two homogenous
/// //result sets, so there is actually no need to check which result set the selector holds and it could
/// //marked with by convention by underscore (_).
Expand All @@ -144,11 +144,11 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
/// {
/// TABLE_CATALOG = selector.GetValueOrDefault&lt;string&gt;("TABLE_CATALOG"),
/// TABLE_NAME = selector.GetValueOrDefault&lt;string&gt;("TABLE_NAME")
/// }
///}).ConfigureAwait(continueOnCapturedContext: false);
/// }
///}).ConfigureAwait(continueOnCapturedContext: false);
/// </code>
/// </example>
public async Task<IEnumerable<TResult>> ReadAsync<TResult>(string query, Action<IDbCommand> parameterProvider, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default(CancellationToken), CommandBehavior commandBehavior = CommandBehavior.Default)
public async Task<IEnumerable<TResult>> ReadAsync<TResult>(string query, Action<IDbCommand> parameterProvider, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CommandBehavior commandBehavior = CommandBehavior.Default, CancellationToken cancellationToken = default(CancellationToken))
{
//If the query is something else that is not acceptable (e.g. an empty string), there will an appropriate database exception.
if(query == null)
Expand All @@ -161,7 +161,7 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
throw new ArgumentNullException(nameof(selector));
}

return (await ExecuteAsync(query, parameterProvider, ExecuteReaderAsync, selector, cancellationToken, commandBehavior).ConfigureAwait(false)).Item1;
return (await ExecuteAsync(query, parameterProvider, ExecuteReaderAsync, selector, commandBehavior, cancellationToken).ConfigureAwait(false)).Item1;
}


Expand All @@ -170,8 +170,8 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
/// </summary>
/// <param name="query">The query to execute.</param>
/// <param name="parameterProvider">Adds parameters to the query. Parameter names must match those defined in the query.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <param name="commandBehavior">The command behavior that should be used. Defaults to <see cref="CommandBehavior.Default"/>.</param>
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
/// <returns>Affected rows count.</returns>
/// <example>This sample shows how to make a hand-tuned database call.
/// <code>
Expand All @@ -183,18 +183,18 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
/// //There aren't parameters here, but they'd be added like when reading.
/// //As the affected rows count is the only thing returned, there isn't
/// //facilities to read anything.
/// }).ConfigureAwait(continueOnCapturedContext: false);
/// }).ConfigureAwait(continueOnCapturedContext: false);
/// </code>
/// </example>
public async Task<int> ExecuteAsync(string query, Action<IDbCommand> parameterProvider, CancellationToken cancellationToken = default(CancellationToken), CommandBehavior commandBehavior = CommandBehavior.Default)
public async Task<int> ExecuteAsync(string query, Action<IDbCommand> parameterProvider, CommandBehavior commandBehavior = CommandBehavior.Default, CancellationToken cancellationToken = default(CancellationToken))
{
//If the query is something else that is not acceptable (e.g. an empty string), there will an appropriate database exception.
if(query == null)
{
throw new ArgumentNullException(nameof(query));
}

return (await ExecuteAsync(query, parameterProvider, ExecuteReaderAsync, (unit, id, c) => Task.FromResult(unit), cancellationToken, commandBehavior).ConfigureAwait(false)).Item2;
return (await ExecuteAsync(query, parameterProvider, ExecuteReaderAsync, (unit, id, c) => Task.FromResult(unit), commandBehavior, cancellationToken).ConfigureAwait(false)).Item2;
}

/// <summary>
Expand Down Expand Up @@ -231,7 +231,7 @@ private static async Task<Tuple<IEnumerable<TResult>, int>> SelectAsync<TResult>
}


private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteReaderAsync<TResult>(DbCommand command, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken, CommandBehavior commandBehavior)
private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteReaderAsync<TResult>(DbCommand command, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CommandBehavior commandBehavior, CancellationToken cancellationToken)
{
using(var reader = await command.ExecuteReaderAsync(commandBehavior, cancellationToken).ConfigureAwait(continueOnCapturedContext: false))
{
Expand All @@ -250,15 +250,15 @@ private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteReaderAsync<TResult>
}
}
}


private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteAsync<TResult>(
string query,
Action<DbCommand> parameterProvider,
Func<DbCommand, Func<IDataRecord, int, CancellationToken, Task<TResult>>, CancellationToken, CommandBehavior, Task<Tuple<IEnumerable<TResult>, int>>> executor,
Func<DbCommand, Func<IDataRecord, int, CancellationToken, Task<TResult>>, CommandBehavior, CancellationToken, Task<Tuple<IEnumerable<TResult>, int>>> executor,
Func<IDataRecord, int, CancellationToken, Task<TResult>> selector,
CancellationToken cancellationToken,
CommandBehavior commandBehavior)
CommandBehavior commandBehavior,
CancellationToken cancellationToken)
{
using (var connection = DbConnectionFactory.CreateConnection(invariantName, connectionString))
{
Expand All @@ -273,11 +273,11 @@ private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteAsync<TResult>(
Task<Tuple<IEnumerable<TResult>, int>> ret;
if(isSynchronousAdoNetImplementation)
{
ret = Task.Run(() => executor(command, selector, cancellationToken, commandBehavior), cancellationToken);
ret = Task.Run(() => executor(command, selector, commandBehavior, cancellationToken), cancellationToken);
}
else
{
ret = executor(command, selector, cancellationToken, commandBehavior);
ret = executor(command, selector, commandBehavior, cancellationToken);
}

return await ret.ConfigureAwait(continueOnCapturedContext: false);
Expand Down
Loading

0 comments on commit e8a8133

Please sign in to comment.