Skip to content

Commit d9374f3

Browse files
Merge pull request #109 from progaudi/fix/async/configure-await
Add ConfigureAwait to all awaits
2 parents 7707b03 + bd13711 commit d9374f3

File tree

8 files changed

+50
-50
lines changed

8 files changed

+50
-50
lines changed

src/progaudi.tarantool/Box.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public Box(ClientOptions options)
2323

2424
public async Task Connect()
2525
{
26-
await _logicalConnection.Connect();
26+
await _logicalConnection.Connect().ConfigureAwait(false);
2727
}
2828

2929
public static async Task<Box> Connect(string replicationSource)
3030
{
3131
var box = new Box(new ClientOptions(replicationSource));
32-
await box.Connect();
32+
await box.Connect().ConfigureAwait(false);
3333
return box;
3434
}
3535

@@ -65,13 +65,13 @@ public ISchema GetSchema()
6565

6666
public async Task Call_1_6(string functionName)
6767
{
68-
await Call_1_6<TarantoolTuple, TarantoolTuple>(functionName, TarantoolTuple.Empty);
68+
await Call_1_6<TarantoolTuple, TarantoolTuple>(functionName, TarantoolTuple.Empty).ConfigureAwait(false);
6969
}
7070

7171
public async Task Call_1_6<TTuple>(string functionName, TTuple parameters)
7272
where TTuple : ITarantoolTuple
7373
{
74-
await Call_1_6<TTuple, TarantoolTuple>(functionName, parameters);
74+
await Call_1_6<TTuple, TarantoolTuple>(functionName, parameters).ConfigureAwait(false);
7575
}
7676

7777
public Task<DataResponse<TResponse[]>> Call_1_6<TResponse>(string functionName)
@@ -85,18 +85,18 @@ public async Task<DataResponse<TResponse[]>> Call_1_6<TTuple, TResponse>(string
8585
where TResponse : ITarantoolTuple
8686
{
8787
var callRequest = new CallRequest<TTuple>(functionName, parameters, false);
88-
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest);
88+
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest).ConfigureAwait(false);
8989
}
9090

9191
public async Task Call(string functionName)
9292
{
93-
await Call<TarantoolTuple, TarantoolTuple>(functionName, TarantoolTuple.Empty);
93+
await Call<TarantoolTuple, TarantoolTuple>(functionName, TarantoolTuple.Empty).ConfigureAwait(false);
9494
}
9595

9696
public async Task Call<TTuple>(string functionName, TTuple parameters)
9797
where TTuple : ITarantoolTuple
9898
{
99-
await Call<TTuple, TarantoolTuple>(functionName, parameters);
99+
await Call<TTuple, TarantoolTuple>(functionName, parameters).ConfigureAwait(false);
100100
}
101101

102102
public Task<DataResponse<TResponse[]>> Call<TResponse>(string functionName)
@@ -108,14 +108,14 @@ public async Task<DataResponse<TResponse[]>> Call<TTuple, TResponse>(string func
108108
where TTuple : ITarantoolTuple
109109
{
110110
var callRequest = new CallRequest<TTuple>(functionName, parameters);
111-
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest);
111+
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest).ConfigureAwait(false);
112112
}
113113

114114
public async Task<DataResponse<TResponse[]>> Eval<TTuple, TResponse>(string expression, TTuple parameters)
115115
where TTuple : ITarantoolTuple
116116
{
117117
var evalRequest = new EvalRequest<TTuple>(expression, parameters);
118-
return await _logicalConnection.SendRequest<EvalRequest<TTuple>, TResponse>(evalRequest);
118+
return await _logicalConnection.SendRequest<EvalRequest<TTuple>, TResponse>(evalRequest).ConfigureAwait(false);
119119
}
120120

121121
public Task<DataResponse<TResponse[]>> Eval<TResponse>(string expression)

src/progaudi.tarantool/Index.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public async Task<DataResponse<TTuple[]>> Select<TKey, TTuple>(TKey key, SelectO
5656
options?.Iterator ?? Iterator.Eq,
5757
key);
5858

59-
return await LogicalConnection.SendRequest<SelectRequest<TKey>, TTuple>(selectRequest);
59+
return await LogicalConnection.SendRequest<SelectRequest<TKey>, TTuple>(selectRequest).ConfigureAwait(false);
6060
}
6161

6262
///Note: there is no such method in specification http://tarantool.org/doc/book/box/box_index.html.
@@ -66,7 +66,7 @@ public async Task<DataResponse<TTuple[]>> Insert<TTuple>(TTuple tuple)
6666
{
6767
var insertRequest = new InsertRequest<TTuple>(SpaceId, tuple);
6868

69-
return await LogicalConnection.SendRequest<InsertReplaceRequest<TTuple>, TTuple>(insertRequest);
69+
return await LogicalConnection.SendRequest<InsertReplaceRequest<TTuple>, TTuple>(insertRequest).ConfigureAwait(false);
7070
}
7171

7272
///Note: there is no such method in specification http://tarantool.org/doc/book/box/box_index.html.
@@ -76,13 +76,13 @@ public async Task<DataResponse<TTuple[]>> Replace<TTuple>(TTuple tuple)
7676
{
7777
var replaceRequest = new ReplaceRequest<TTuple>(SpaceId, tuple);
7878

79-
return await LogicalConnection.SendRequest<InsertReplaceRequest<TTuple>, TTuple>(replaceRequest);
79+
return await LogicalConnection.SendRequest<InsertReplaceRequest<TTuple>, TTuple>(replaceRequest).ConfigureAwait(false);
8080
}
8181

8282
public async Task<TTuple> Min<TTuple>()
8383
where TTuple : ITarantoolTuple
8484
{
85-
return await Min<TTuple, TarantoolTuple>(TarantoolTuple.Empty);
85+
return await Min<TTuple, TarantoolTuple>(TarantoolTuple.Empty).ConfigureAwait(false);
8686
}
8787

8888
public async Task<TTuple> Min<TTuple, TKey>(TKey key)
@@ -97,14 +97,14 @@ public async Task<TTuple> Min<TTuple, TKey>(TKey key)
9797

9898
var selectPacket = new SelectRequest<TKey>(SpaceId, Id, 1, 0, iterator, key);
9999

100-
var minResponse = await LogicalConnection.SendRequest<SelectRequest<TKey>, TTuple>(selectPacket);
100+
var minResponse = await LogicalConnection.SendRequest<SelectRequest<TKey>, TTuple>(selectPacket).ConfigureAwait(false);
101101
return minResponse.Data.SingleOrDefault();
102102
}
103103

104104
public async Task<TTuple> Max<TTuple>()
105105
where TTuple : ITarantoolTuple
106106
{
107-
return await Max<TTuple, TarantoolTuple>(TarantoolTuple.Empty);
107+
return await Max<TTuple, TarantoolTuple>(TarantoolTuple.Empty).ConfigureAwait(false);
108108
}
109109

110110
public async Task<TTuple> Max<TTuple, TKey>(TKey key = null)
@@ -119,7 +119,7 @@ public async Task<TTuple> Max<TTuple, TKey>(TKey key = null)
119119

120120
var selectPacket = new SelectRequest<TKey>(SpaceId, Id, 1, 0, iterator, key);
121121

122-
var maxResponse = await LogicalConnection.SendRequest<SelectRequest<TKey>, TTuple>(selectPacket);
122+
var maxResponse = await LogicalConnection.SendRequest<SelectRequest<TKey>, TTuple>(selectPacket).ConfigureAwait(false);
123123
return maxResponse.Data.SingleOrDefault();
124124
}
125125

@@ -145,7 +145,7 @@ public async Task<DataResponse<TTuple[]>> Update<TTuple, TKey>(TKey key, UpdateO
145145
key,
146146
updateOperations);
147147

148-
return await LogicalConnection.SendRequest<UpdateRequest<TKey>, TTuple>(updateRequest);
148+
return await LogicalConnection.SendRequest<UpdateRequest<TKey>, TTuple>(updateRequest).ConfigureAwait(false);
149149
}
150150

151151
public async Task Upsert<TKey>(TKey key, UpdateOperation[] updateOperations)
@@ -156,7 +156,7 @@ public async Task Upsert<TKey>(TKey key, UpdateOperation[] updateOperations)
156156
key,
157157
updateOperations);
158158

159-
await LogicalConnection.SendRequestWithEmptyResponse(updateRequest);
159+
await LogicalConnection.SendRequestWithEmptyResponse(updateRequest).ConfigureAwait(false);
160160
}
161161

162162
public async Task<DataResponse<TTuple[]>> Delete<TKey, TTuple>(TKey key)
@@ -165,7 +165,7 @@ public async Task<DataResponse<TTuple[]>> Delete<TKey, TTuple>(TKey key)
165165
{
166166
var deleteRequest = new DeleteRequest<TKey>(SpaceId, Id, key);
167167

168-
return await LogicalConnection.SendRequest<DeleteRequest<TKey>, TTuple>(deleteRequest);
168+
return await LogicalConnection.SendRequest<DeleteRequest<TKey>, TTuple>(deleteRequest).ConfigureAwait(false);
169169
}
170170

171171
public Task Alter(IndexCreationOptions options)

src/progaudi.tarantool/LogicalConnection.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public void Dispose()
6666

6767
public async Task Connect()
6868
{
69-
await _physicalConnection.Connect(_clientOptions);
69+
await _physicalConnection.Connect(_clientOptions).ConfigureAwait(false);
7070

7171
var greetingsResponseBytes = new byte[128];
72-
var readCount = await _physicalConnection.ReadAsync(greetingsResponseBytes, 0, greetingsResponseBytes.Length);
72+
var readCount = await _physicalConnection.ReadAsync(greetingsResponseBytes, 0, greetingsResponseBytes.Length).ConfigureAwait(false);
7373
if (readCount != greetingsResponseBytes.Length)
7474
{
7575
throw ExceptionHelper.UnexpectedGreetingBytesCount(readCount);
@@ -86,7 +86,7 @@ public async Task Connect()
8686

8787
_clientOptions.LogWriter?.WriteLine("Server responses reading started.");
8888

89-
await LoginIfNotGuest(greetings);
89+
await LoginIfNotGuest(greetings).ConfigureAwait(false);
9090
}
9191

9292
public bool IsConnected()
@@ -111,20 +111,20 @@ private async Task LoginIfNotGuest(GreetingsResponse greetings)
111111

112112
var authenticateRequest = AuthenticationRequest.Create(greetings, singleNode.Uri);
113113

114-
await SendRequestWithEmptyResponse(authenticateRequest);
114+
await SendRequestWithEmptyResponse(authenticateRequest).ConfigureAwait(false);
115115
_clientOptions.LogWriter?.WriteLine($"Authentication request send: {authenticateRequest}");
116116
}
117117

118118
public async Task SendRequestWithEmptyResponse<TRequest>(TRequest request, TimeSpan? timeout = null)
119119
where TRequest : IRequest
120120
{
121-
await SendRequestImpl<TRequest, EmptyResponse>(request, timeout);
121+
await SendRequestImpl<TRequest, EmptyResponse>(request, timeout).ConfigureAwait(false);
122122
}
123123

124124
public async Task<DataResponse<TResponse[]>> SendRequest<TRequest, TResponse>(TRequest request, TimeSpan? timeout = null)
125125
where TRequest : IRequest
126126
{
127-
return await SendRequestImpl<TRequest, DataResponse<TResponse[]>>(request, timeout);
127+
return await SendRequestImpl<TRequest, DataResponse<TResponse[]>>(request, timeout).ConfigureAwait(false);
128128
}
129129

130130
private async Task<TResponse> SendRequestImpl<TRequest, TResponse>(TRequest request, TimeSpan? timeout)
@@ -153,7 +153,7 @@ await _responseWriter.Write(
153153
responseTask = responseTask.WithCancellation(cts.Token);
154154
}
155155

156-
var responseStream = await responseTask;
156+
var responseStream = await responseTask.ConfigureAwait(false);
157157
_logWriter?.WriteLine($"Response with requestId {requestId} is recieved, length: {responseStream.Length}.");
158158

159159
return MsgPackSerializer.Deserialize<TResponse>(responseStream, _msgPackContext);

src/progaudi.tarantool/LogicalConnectionManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public async Task Connect()
9090
_clientOptions.LogWriter?.WriteLine($"{nameof(LogicalConnectionManager)}: Connecting...");
9191

9292
var newConnection = new LogicalConnection(_clientOptions, _requestIdCounter);
93-
await newConnection.Connect();
93+
await newConnection.Connect().ConfigureAwait(false);;
9494
Interlocked.Exchange(ref _droppableLogicalConnection, newConnection)?.Dispose();
9595

9696
_connected.Set();
@@ -160,9 +160,9 @@ private void ScheduleNextPing()
160160

161161
public async Task<DataResponse<TResponse[]>> SendRequest<TRequest, TResponse>(TRequest request, TimeSpan? timeout = null) where TRequest : IRequest
162162
{
163-
await Connect();
163+
await Connect().ConfigureAwait(false);
164164

165-
var result = await _droppableLogicalConnection.SendRequest<TRequest, TResponse>(request, timeout);
165+
var result = await _droppableLogicalConnection.SendRequest<TRequest, TResponse>(request, timeout).ConfigureAwait(false);
166166

167167
ScheduleNextPing();
168168

@@ -171,9 +171,9 @@ public async Task<DataResponse<TResponse[]>> SendRequest<TRequest, TResponse>(TR
171171

172172
public async Task SendRequestWithEmptyResponse<TRequest>(TRequest request, TimeSpan? timeout = null) where TRequest : IRequest
173173
{
174-
await Connect();
174+
await Connect().ConfigureAwait(false);
175175

176-
await _droppableLogicalConnection.SendRequestWithEmptyResponse(request, timeout);
176+
await _droppableLogicalConnection.SendRequestWithEmptyResponse(request, timeout).ConfigureAwait(false);
177177

178178
ScheduleNextPing();
179179
}

src/progaudi.tarantool/NetworkStreamPhysicalConnection.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task Connect(ClientOptions options)
4343
{
4444
NoDelay = true
4545
};
46-
await ConnectAsync(_socket, singleNode.Uri.Host, singleNode.Uri.Port);
46+
await ConnectAsync(_socket, singleNode.Uri.Host, singleNode.Uri.Port).ConfigureAwait(false);;
4747

4848
_stream = new NetworkStream(_socket, true);
4949
options.LogWriter?.WriteLine("Socket connection established.");
@@ -58,25 +58,25 @@ public void Write(byte[] buffer, int offset, int count)
5858
public async Task Flush()
5959
{
6060
CheckConnectionStatus();
61-
await _stream.FlushAsync();
61+
await _stream.FlushAsync().ConfigureAwait(false);
6262
}
6363

6464
public async Task<int> ReadAsync(byte[] buffer, int offset, int count)
6565
{
6666
CheckConnectionStatus();
67-
return await _stream.ReadAsync(buffer, offset, count);
67+
return await _stream.ReadAsync(buffer, offset, count).ConfigureAwait(false);
6868
}
6969

7070
#if PROGAUDI_NETCORE
7171
/// https://github.com/mongodb/mongo-csharp-driver/commit/9c2097f349d5096a04ea81b0c9ceb60c7e1acee4
7272
private static async Task ConnectAsync(Socket socket, string host, int port)
7373
{
74-
var resolved = await Dns.GetHostAddressesAsync(host);
74+
var resolved = await Dns.GetHostAddressesAsync(host).ConfigureAwait(false);;
7575
for (var i = 0; i < resolved.Length; i++)
7676
{
7777
try
7878
{
79-
await socket.ConnectAsync(resolved[i], port);
79+
await socket.ConnectAsync(resolved[i], port).ConfigureAwait(false);
8080
return;
8181
}
8282
catch

src/progaudi.tarantool/Schema.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public async Task<ISpace> GetSpace(string name)
3333
{
3434
var selectIndexRequest = new SelectRequest<TarantoolTuple<string>>(VSpace, SpaceByName, uint.MaxValue, 0, Iterator.Eq, TarantoolTuple.Create(name));
3535

36-
var response = await _logicalConnection.SendRequest<SelectRequest<TarantoolTuple<string>>, Space>(selectIndexRequest);
36+
var response = await _logicalConnection.SendRequest<SelectRequest<TarantoolTuple<string>>, Space>(selectIndexRequest).ConfigureAwait(false);
3737

3838
var result = response.Data.SingleOrDefault();
3939
if (result == null)
@@ -50,7 +50,7 @@ public async Task<ISpace> GetSpace(uint id)
5050
{
5151
var selectIndexRequest = new SelectRequest<TarantoolTuple<uint>>(VSpace, SpaceById, uint.MaxValue, 0, Iterator.Eq, TarantoolTuple.Create(id));
5252

53-
var response = await _logicalConnection.SendRequest<SelectRequest<TarantoolTuple<uint>>, Space>(selectIndexRequest);
53+
var response = await _logicalConnection.SendRequest<SelectRequest<TarantoolTuple<uint>>, Space>(selectIndexRequest).ConfigureAwait(false);
5454

5555
var result = response.Data.SingleOrDefault();
5656
if (result == null)

0 commit comments

Comments
 (0)