Skip to content

Commit 57a5251

Browse files
committed
Continue removing sync API
Part of #1472 * Remove the last sync I/O method from `IFrameHandler` Update action versions to address Node.js warnings * Remove use of `EnsureCompleted` * Handle connection start using async/await * Remove `EnsureCompleted` task extensions. * Remove `BasicConsumeRpcContinuation` * Update action versions to address Node.js warnings * Remove non-async RPC continuation classes * Remove unused classes * Address some TODOs * Set a `TimeoutException` when an async RPC continuation times out
1 parent ec129ba commit 57a5251

19 files changed

+53
-721
lines changed

.github/workflows/build-test.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
submodules: true
1717
- name: Cache NuGet packages
18-
uses: actions/cache@v3
18+
uses: actions/cache@v4
1919
with:
2020
path: |
2121
~/.nuget/packages
@@ -32,7 +32,7 @@ jobs:
3232
- name: Unit Tests
3333
run: dotnet test "${{ github.workspace }}\projects\Test\Unit\Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
3434
- name: Upload Build (Debug)
35-
uses: actions/upload-artifact@v3
35+
uses: actions/upload-artifact@v4
3636
with:
3737
name: rabbitmq-dotnet-client-build-win32
3838
path: |
@@ -52,14 +52,14 @@ jobs:
5252
with:
5353
submodules: true
5454
- name: Cache installers
55-
uses: actions/cache@v3
55+
uses: actions/cache@v4
5656
with:
5757
# Note: the cache path is relative to the workspace directory
5858
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
5959
path: ~/installers
6060
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
6161
- name: Download Build (Debug)
62-
uses: actions/download-artifact@v3
62+
uses: actions/download-artifact@v4
6363
with:
6464
name: rabbitmq-dotnet-client-build-win32
6565
path: projects
@@ -81,7 +81,7 @@ jobs:
8181
"${{ github.workspace }}\projects\Test\Integration\Integration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
8282
- name: Maybe upload RabbitMQ logs
8383
if: failure()
84-
uses: actions/upload-artifact@v3
84+
uses: actions/upload-artifact@v4
8585
with:
8686
name: rabbitmq-logs-integration-win32
8787
path: ~/AppData/Roaming/RabbitMQ/log/
@@ -97,14 +97,14 @@ jobs:
9797
with:
9898
submodules: true
9999
- name: Cache installers
100-
uses: actions/cache@v3
100+
uses: actions/cache@v4
101101
with:
102102
# Note: the cache path is relative to the workspace directory
103103
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
104104
path: ~/installers
105105
key: ${{ runner.os }}-v0-${{ hashFiles('.ci/versions.json') }}
106106
- name: Download Build (Debug)
107-
uses: actions/download-artifact@v3
107+
uses: actions/download-artifact@v4
108108
with:
109109
name: rabbitmq-dotnet-client-build-win32
110110
path: projects
@@ -115,7 +115,7 @@ jobs:
115115
run: dotnet test --environment "RABBITMQ_RABBITMQCTL_PATH=${{ steps.install-start-rabbitmq.outputs.path }}" "${{ github.workspace }}\projects\Test\SequentialIntegration\SequentialIntegration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
116116
- name: Maybe upload RabbitMQ logs
117117
if: failure()
118-
uses: actions/upload-artifact@v3
118+
uses: actions/upload-artifact@v4
119119
with:
120120
name: rabbitmq-logs-sequential-integration-win32
121121
path: ~/AppData/Roaming/RabbitMQ/log/
@@ -128,11 +128,11 @@ jobs:
128128
with:
129129
submodules: true
130130
- name: Setup .NET
131-
uses: actions/setup-dotnet@v3
131+
uses: actions/setup-dotnet@v4
132132
with:
133133
dotnet-version: 6.x
134134
- name: Cache NuGet packages
135-
uses: actions/cache@v3
135+
uses: actions/cache@v4
136136
with:
137137
path: |
138138
~/.nuget/packages
@@ -149,7 +149,7 @@ jobs:
149149
- name: Unit Tests
150150
run: dotnet test "${{ github.workspace }}/projects/Test/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
151151
- name: Upload Build (Debug)
152-
uses: actions/upload-artifact@v3
152+
uses: actions/upload-artifact@v4
153153
with:
154154
name: rabbitmq-dotnet-client-build-ubuntu
155155
path: |
@@ -166,11 +166,11 @@ jobs:
166166
with:
167167
submodules: true
168168
- name: Setup .NET
169-
uses: actions/setup-dotnet@v3
169+
uses: actions/setup-dotnet@v4
170170
with:
171171
dotnet-version: 6.x
172172
- name: Download Build (Debug)
173-
uses: actions/download-artifact@v3
173+
uses: actions/download-artifact@v4
174174
with:
175175
name: rabbitmq-dotnet-client-build-ubuntu
176176
path: projects
@@ -188,7 +188,7 @@ jobs:
188188
"${{ github.workspace }}/projects/Test/Integration/Integration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
189189
- name: Maybe upload RabbitMQ logs
190190
if: failure()
191-
uses: actions/upload-artifact@v3
191+
uses: actions/upload-artifact@v4
192192
with:
193193
name: rabbitmq-logs-integration-ubuntu
194194
path: ${{ github.workspace }}/.ci/ubuntu/log/
@@ -201,11 +201,11 @@ jobs:
201201
with:
202202
submodules: true
203203
- name: Setup .NET
204-
uses: actions/setup-dotnet@v3
204+
uses: actions/setup-dotnet@v4
205205
with:
206206
dotnet-version: 6.x
207207
- name: Download Build (Debug)
208-
uses: actions/download-artifact@v3
208+
uses: actions/download-artifact@v4
209209
with:
210210
name: rabbitmq-dotnet-client-build-ubuntu
211211
path: projects
@@ -219,7 +219,7 @@ jobs:
219219
"${{ github.workspace }}/projects/Test/SequentialIntegration/SequentialIntegration.csproj" --no-restore --no-build --logger 'console;verbosity=detailed'
220220
- name: Maybe upload RabbitMQ logs
221221
if: failure()
222-
uses: actions/upload-artifact@v3
222+
uses: actions/upload-artifact@v4
223223
with:
224224
name: rabbitmq-logs-sequential-integration-ubuntu
225225
path: ${{ github.workspace }}/.ci/ubuntu/log/

.github/workflows/oauth2.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
- uses: actions/checkout@v4
1818
with:
1919
submodules: true
20-
- uses: actions/setup-dotnet@v3
20+
- uses: actions/setup-dotnet@v4
2121
with:
2222
dotnet-version: 6.x
23-
- uses: actions/cache@v3
23+
- uses: actions/cache@v4
2424
with:
2525
path: |
2626
~/.nuget/packages

.github/workflows/publish-nuget.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414
with:
1515
submodules: true
16-
- uses: actions/cache@v3
16+
- uses: actions/cache@v4
1717
with:
1818
path: |
1919
~/.nuget/packages

projects/Benchmarks/Networking/Networking_BasicDeliver_LongLivedConnection.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void GlobalSetup()
2222

2323
var cf = new ConnectionFactory { ConsumerDispatchConcurrency = 2 };
2424
// TODO / NOTE: https://github.com/dotnet/BenchmarkDotNet/issues/1738
25-
_connection = cf.CreateConnectionAsync().EnsureCompleted();
25+
_connection = EnsureCompleted(cf.CreateConnectionAsync());
2626
}
2727

2828
[GlobalCleanup]
@@ -37,5 +37,7 @@ public Task Publish_Hello_World()
3737
{
3838
return Networking_BasicDeliver_Commons.Publish_Hello_World(_connection, messageCount, _body);
3939
}
40+
41+
private static T EnsureCompleted<T>(Task<T> task) => task.GetAwaiter().GetResult();
4042
}
4143
}

projects/RabbitMQ.Client/client/TaskExtensions.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -203,34 +203,6 @@ static async ValueTask DoTimeoutAfter(ValueTask valueTask, TimeSpan timeout)
203203
#endif
204204
}
205205

206-
/*
207-
* https://devblogs.microsoft.com/dotnet/configureawait-faq/
208-
* I'm using GetAwaiter().GetResult(). Do I need to use ConfigureAwait(false)?
209-
* Answer: No
210-
*/
211-
public static void EnsureCompleted(this Task task)
212-
{
213-
task.GetAwaiter().GetResult();
214-
}
215-
216-
public static T EnsureCompleted<T>(this Task<T> task)
217-
{
218-
return task.GetAwaiter().GetResult();
219-
}
220-
221-
public static T EnsureCompleted<T>(this ValueTask<T> task)
222-
{
223-
return task.GetAwaiter().GetResult();
224-
}
225-
226-
public static void EnsureCompleted(this ValueTask task)
227-
{
228-
if (false == task.IsCompletedSuccessfully)
229-
{
230-
task.GetAwaiter().GetResult();
231-
}
232-
}
233-
234206
#if NETSTANDARD
235207
// https://github.com/dotnet/runtime/issues/23878
236208
// https://github.com/dotnet/runtime/issues/23878#issuecomment-1398958645

projects/RabbitMQ.Client/client/framing/Channel.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,19 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
108108
}
109109
case ProtocolCommandId.BasicCancelOk:
110110
{
111-
bool result = HandleBasicCancelOk(in cmd);
112-
return Task.FromResult(result);
111+
return Task.FromResult(false);
113112
}
114113
case ProtocolCommandId.BasicConsumeOk:
115114
{
116-
bool result = HandleBasicConsumeOk(in cmd);
117-
return Task.FromResult(result);
115+
return Task.FromResult(false);
118116
}
119117
case ProtocolCommandId.BasicGetEmpty:
120118
{
121-
bool result = HandleBasicGetEmpty(in cmd);
122-
return Task.FromResult(result);
119+
return Task.FromResult(false);
123120
}
124121
case ProtocolCommandId.BasicGetOk:
125122
{
126-
bool result = HandleBasicGetOk(in cmd);
127-
return Task.FromResult(result);
123+
return Task.FromResult(false);
128124
}
129125
case ProtocolCommandId.BasicNack:
130126
{
@@ -165,8 +161,7 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
165161
}
166162
case ProtocolCommandId.ConnectionStart:
167163
{
168-
HandleConnectionStart(in cmd);
169-
return Task.FromResult(true);
164+
return HandleConnectionStartAsync(cmd, cancellationToken);
170165
}
171166
case ProtocolCommandId.ConnectionTune:
172167
{

projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout)
6868
// TODO LRB rabbitmq/rabbitmq-dotnet-client#1347
6969
// Cancellation was successful, does this mean we should set a TimeoutException
7070
// in the same manner as BlockingCell?
71+
tcs.SetException(new TimeoutException("TODO LRB rabbitmq/rabbitmq-dotnet-client#1347"));
7172
}
7273
}, _tcs);
7374
#else

projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ internal AutorecoveringConnection(ConnectionConfig config, IEndpointResolver end
6565
_endpoints = endpoints;
6666
}
6767

68-
internal IConnection Open()
69-
{
70-
IFrameHandler fh = _endpoints.SelectOneAsync(_config.FrameHandlerFactoryAsync, CancellationToken.None).EnsureCompleted();
71-
CreateInnerConnection(fh);
72-
_innerConnection.Open();
73-
return this;
74-
}
75-
7668
internal async ValueTask<IConnection> OpenAsync(CancellationToken cancellationToken)
7769
{
7870
IFrameHandler fh = await _endpoints.SelectOneAsync(_config.FrameHandlerFactoryAsync, cancellationToken)

0 commit comments

Comments
 (0)