Skip to content

Commit e8a8133

Browse files
authored
Merge branch 'main' into main
2 parents 689179a + ea3372c commit e8a8133

File tree

179 files changed

+396
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+396
-366
lines changed

src/AWS/Orleans.Clustering.DynamoDB/Membership/DynamoDBGatewayListProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Orleans.Clustering.DynamoDB
1616
internal class DynamoDBGatewayListProvider : IGatewayListProvider
1717
{
1818
private DynamoDBStorage storage;
19-
private string clusterId;
19+
private readonly string clusterId;
2020
private readonly string INSTANCE_STATUS_ACTIVE = ((int)SiloStatus.Active).ToString();
2121
private readonly ILogger logger;
2222
private readonly DynamoDBGatewayOptions options;

src/AWS/Orleans.Streaming.SQS/Storage/SQSStorage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal class SQSStorage
2525
private const string AccessKeyPropertyName = "AccessKey";
2626
private const string SecretKeyPropertyName = "SecretKey";
2727
private const string ServicePropertyName = "Service";
28-
private ILogger Logger;
28+
private readonly ILogger Logger;
2929
private string accessKey;
3030
private string secretKey;
3131
private string service;

src/AWS/Orleans.Streaming.SQS/Streams/SQSAdapterFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public class SQSAdapterFactory : IQueueAdapterFactory
2020
private readonly ClusterOptions clusterOptions;
2121
private readonly Serializer<SQSBatchContainer> serializer;
2222
private readonly ILoggerFactory loggerFactory;
23-
private HashRingBasedStreamQueueMapper streamQueueMapper;
24-
private IQueueAdapterCache adapterCache;
23+
private readonly HashRingBasedStreamQueueMapper streamQueueMapper;
24+
private readonly IQueueAdapterCache adapterCache;
2525

2626
/// <summary>
2727
/// Application level failure handler override.

src/AWS/Shared/Storage/DynamoDBStorage.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ namespace Orleans.Transactions.DynamoDB
3030
/// </summary>
3131
internal class DynamoDBStorage
3232
{
33-
private string accessKey;
34-
private string token;
35-
private string profileName;
33+
private readonly string accessKey;
34+
private readonly string token;
35+
private readonly string profileName;
3636
/// <summary> Secret key for this dynamoDB table </summary>
3737
protected string secretKey;
38-
private string service;
38+
private readonly string service;
3939
public const int DefaultReadCapacityUnits = 10;
4040
public const int DefaultWriteCapacityUnits = 5;
4141
private readonly ProvisionedThroughput provisionedThroughput;
@@ -47,7 +47,7 @@ internal class DynamoDBStorage
4747
TableStatus.CREATING, TableStatus.UPDATING, TableStatus.ACTIVE
4848
});
4949
private AmazonDynamoDBClient ddbClient;
50-
private ILogger Logger;
50+
private readonly ILogger Logger;
5151

5252
/// <summary>
5353
/// Create a DynamoDBStorage instance

src/AdoNet/Orleans.Clustering.AdoNet/Messaging/AdoNetClusteringTable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace Orleans.Runtime.MembershipService
1010
{
1111
public class AdoNetClusteringTable : IMembershipTable
1212
{
13-
private string clusterId;
13+
private readonly string clusterId;
1414
private readonly IServiceProvider serviceProvider;
15-
private ILogger logger;
15+
private readonly ILogger logger;
1616
private RelationalOrleansQueries orleansQueries;
1717
private readonly AdoNetClusteringSiloOptions clusteringTableOptions;
1818

src/AdoNet/Orleans.Clustering.AdoNet/Messaging/AdoNetGatewayListProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Orleans.Runtime.Membership
1313
public class AdoNetGatewayListProvider : IGatewayListProvider
1414
{
1515
private readonly ILogger logger;
16-
private string clusterId;
16+
private readonly string clusterId;
1717
private readonly AdoNetClusteringClientOptions options;
1818
private RelationalOrleansQueries orleansQueries;
1919
private readonly IServiceProvider serviceProvider;

src/AdoNet/Orleans.Persistence.AdoNet/Storage/Provider/AdoNetGrainStorage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public async Task ClearStateAsync<T>(string grainType, GrainId grainReference, I
189189
command.AddParameter("GrainIdExtensionString", grainId.StringKey);
190190
command.AddParameter("ServiceId", serviceId);
191191
command.AddParameter("GrainStateVersion", !string.IsNullOrWhiteSpace(grainState.ETag) ? int.Parse(grainState.ETag, CultureInfo.InvariantCulture) : default(int?));
192-
}, (selector, resultSetCount, token) => Task.FromResult(selector.GetValue(0).ToString()), CancellationToken.None).ConfigureAwait(false));
192+
}, (selector, resultSetCount, token) => Task.FromResult(selector.GetValue(0).ToString()), cancellationToken: CancellationToken.None).ConfigureAwait(false));
193193
storageVersion = clearRecord.SingleOrDefault();
194194
}
195195
catch(Exception ex)
@@ -282,7 +282,7 @@ public async Task ReadStateAsync<T>(string grainType, GrainId grainReference, IG
282282
var result = Tuple.Create(storageState, version?.ToString(CultureInfo.InvariantCulture));
283283
return Task.FromResult(result);
284284
},
285-
CancellationToken.None, commandBehavior).ConfigureAwait(false)).SingleOrDefault();
285+
commandBehavior, CancellationToken.None).ConfigureAwait(false)).SingleOrDefault();
286286

287287
T state = readRecords != null ? (T) readRecords.Item1 : default;
288288
string etag = readRecords != null ? readRecords.Item2 : null;
@@ -371,7 +371,7 @@ public async Task WriteStateAsync<T>(string grainType, GrainId grainReference, I
371371
command.AddParameter("GrainStateVersion", !string.IsNullOrWhiteSpace(grainState.ETag) ? int.Parse(grainState.ETag, CultureInfo.InvariantCulture) : default(int?));
372372
command.AddParameter("PayloadBinary", serialized.ToArray());
373373
}, (selector, resultSetCount, token) =>
374-
{ return Task.FromResult(selector.GetNullableInt32("NewGrainStateVersion").ToString()); }, CancellationToken.None).ConfigureAwait(false);
374+
{ return Task.FromResult(selector.GetNullableInt32("NewGrainStateVersion").ToString()); }, cancellationToken: CancellationToken.None).ConfigureAwait(false);
375375
storageVersion = writeRecord.SingleOrDefault();
376376
}
377377
catch(Exception ex)

src/AdoNet/Shared/Storage/IRelationalStorage.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ internal interface IRelationalStorage
3232
/// <param name="query">The query to execute.</param>
3333
/// <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>
3434
/// <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>
35-
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
3635
/// <param name="commandBehavior">The command behavior that should be used. Defaults to <see cref="CommandBehavior.Default"/>.</param>
36+
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
3737
/// <returns>A list of objects as a result of the <see paramref="query"/>.</returns>
3838
/// <example>This sample shows how to make a hand-tuned database call.
3939
/// <code>
@@ -58,7 +58,7 @@ internal interface IRelationalStorage
5858
/// tp1.DbType = DbType.String;
5959
/// tp1.Direction = ParameterDirection.Input;
6060
/// command.Parameters.Add(tp1);
61-
///
61+
///
6262
/// //The selector is used to select the results within the result set. In this case there are two homogenous
6363
/// //result sets, so there is actually no need to check which result set the selector holds and it could
6464
/// //marked with by convention by underscore (_).
@@ -70,19 +70,19 @@ internal interface IRelationalStorage
7070
/// {
7171
/// TABLE_CATALOG = selector.GetValueOrDefault&lt;string&gt;("TABLE_CATALOG"),
7272
/// TABLE_NAME = selector.GetValueOrDefault&lt;string&gt;("TABLE_NAME")
73-
/// }
74-
///}).ConfigureAwait(continueOnCapturedContext: false);
75-
/// </code>
73+
/// }
74+
///}).ConfigureAwait(continueOnCapturedContext: false);
75+
/// </code>
7676
/// </example>
77-
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);
77+
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));
7878

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

102102
/// <summary>
103103
/// The well known invariant name of the underlying database.

src/AdoNet/Shared/Storage/RelationalStorage.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Orleans.Tests.SqlUtils
2121
{
2222
/// <summary>
2323
/// A general purpose class to work with a given relational database and ADO.NET provider.
24-
/// </summary>
24+
/// </summary>
2525
[DebuggerDisplay("InvariantName = {InvariantName}, ConnectionString = {ConnectionString}")]
2626
internal class RelationalStorage: IRelationalStorage
2727
{
@@ -103,11 +103,11 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
103103
/// Executes a given statement. Especially intended to use with <em>SELECT</em> statement.
104104
/// </summary>
105105
/// <typeparam name="TResult">The result type.</typeparam>
106-
/// <param name="query">Executes a given statement. Especially intended to use with <em>SELECT</em> statement.</param>
106+
/// <param name="query">Executes a given statement. Especially intended to use with <em>SELECT</em> statement.</param>
107107
/// <param name="parameterProvider">Adds parameters to the query. Parameter names must match those defined in the query.</param>
108108
/// <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>
109-
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
110109
/// <param name="commandBehavior">The command behavior that should be used. Defaults to <see cref="CommandBehavior.Default"/>.</param>
110+
/// <param name="cancellationToken">The cancellation token. Defaults to <see cref="CancellationToken.None"/>.</param>
111111
/// <returns>A list of objects as a result of the <see paramref="query"/>.</returns>
112112
/// <example>This sample shows how to make a hand-tuned database call.
113113
/// <code>
@@ -132,7 +132,7 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
132132
/// tp1.DbType = DbType.String;
133133
/// tp1.Direction = ParameterDirection.Input;
134134
/// command.Parameters.Add(tp1);
135-
///
135+
///
136136
/// //The selector is used to select the results within the result set. In this case there are two homogenous
137137
/// //result sets, so there is actually no need to check which result set the selector holds and it could
138138
/// //marked with by convention by underscore (_).
@@ -144,11 +144,11 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
144144
/// {
145145
/// TABLE_CATALOG = selector.GetValueOrDefault&lt;string&gt;("TABLE_CATALOG"),
146146
/// TABLE_NAME = selector.GetValueOrDefault&lt;string&gt;("TABLE_NAME")
147-
/// }
148-
///}).ConfigureAwait(continueOnCapturedContext: false);
147+
/// }
148+
///}).ConfigureAwait(continueOnCapturedContext: false);
149149
/// </code>
150150
/// </example>
151-
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)
151+
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))
152152
{
153153
//If the query is something else that is not acceptable (e.g. an empty string), there will an appropriate database exception.
154154
if(query == null)
@@ -161,7 +161,7 @@ public static IRelationalStorage CreateInstance(string invariantName, string con
161161
throw new ArgumentNullException(nameof(selector));
162162
}
163163

164-
return (await ExecuteAsync(query, parameterProvider, ExecuteReaderAsync, selector, cancellationToken, commandBehavior).ConfigureAwait(false)).Item1;
164+
return (await ExecuteAsync(query, parameterProvider, ExecuteReaderAsync, selector, commandBehavior, cancellationToken).ConfigureAwait(false)).Item1;
165165
}
166166

167167

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

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

200200
/// <summary>
@@ -231,7 +231,7 @@ private static async Task<Tuple<IEnumerable<TResult>, int>> SelectAsync<TResult>
231231
}
232232

233233

234-
private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteReaderAsync<TResult>(DbCommand command, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken, CommandBehavior commandBehavior)
234+
private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteReaderAsync<TResult>(DbCommand command, Func<IDataRecord, int, CancellationToken, Task<TResult>> selector, CommandBehavior commandBehavior, CancellationToken cancellationToken)
235235
{
236236
using(var reader = await command.ExecuteReaderAsync(commandBehavior, cancellationToken).ConfigureAwait(continueOnCapturedContext: false))
237237
{
@@ -250,15 +250,15 @@ private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteReaderAsync<TResult>
250250
}
251251
}
252252
}
253-
253+
254254

255255
private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteAsync<TResult>(
256256
string query,
257257
Action<DbCommand> parameterProvider,
258-
Func<DbCommand, Func<IDataRecord, int, CancellationToken, Task<TResult>>, CancellationToken, CommandBehavior, Task<Tuple<IEnumerable<TResult>, int>>> executor,
258+
Func<DbCommand, Func<IDataRecord, int, CancellationToken, Task<TResult>>, CommandBehavior, CancellationToken, Task<Tuple<IEnumerable<TResult>, int>>> executor,
259259
Func<IDataRecord, int, CancellationToken, Task<TResult>> selector,
260-
CancellationToken cancellationToken,
261-
CommandBehavior commandBehavior)
260+
CommandBehavior commandBehavior,
261+
CancellationToken cancellationToken)
262262
{
263263
using (var connection = DbConnectionFactory.CreateConnection(invariantName, connectionString))
264264
{
@@ -273,11 +273,11 @@ private async Task<Tuple<IEnumerable<TResult>, int>> ExecuteAsync<TResult>(
273273
Task<Tuple<IEnumerable<TResult>, int>> ret;
274274
if(isSynchronousAdoNetImplementation)
275275
{
276-
ret = Task.Run(() => executor(command, selector, cancellationToken, commandBehavior), cancellationToken);
276+
ret = Task.Run(() => executor(command, selector, commandBehavior, cancellationToken), cancellationToken);
277277
}
278278
else
279279
{
280-
ret = executor(command, selector, cancellationToken, commandBehavior);
280+
ret = executor(command, selector, commandBehavior, cancellationToken);
281281
}
282282

283283
return await ret.ConfigureAwait(continueOnCapturedContext: false);

0 commit comments

Comments
 (0)