Skip to content

Commit 52add14

Browse files
authored
Merge pull request #1473 from rabbitmq/rabbitmq-dotnet-client-1472
Remove synchronous API
2 parents f8a3028 + b65e07e commit 52add14

File tree

110 files changed

+3349
-4250
lines changed

Some content is hidden

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

110 files changed

+3349
-4250
lines changed

build.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if ($RunTests)
2323
foreach ($csproj_file in $unit_csproj_file, $integration_csproj_file, $async_integration_csproj_file, $sequential_integration_csproj_file)
2424
{
2525
Write-Host "[INFO] running Unit / Integration tests from '$csproj_file' (all frameworks)" -ForegroundColor "Magenta"
26-
dotnet test $csproj_file --no-restore --no-build --logger "console;verbosity=detailed"
26+
dotnet test $csproj_file --environment 'RABBITMQ_LONG_RUNNING_TESTS=true' --no-restore --no-build --logger "console;verbosity=detailed"
2727
if ($LASTEXITCODE -ne 0)
2828
{
2929
Write-Host "[ERROR] tests errored, exiting" -Foreground "Red"

projects/Benchmarks/Benchmarks.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="BenchmarkDotNet" Version="0.13.11" />
18+
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
1919
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
2020
</ItemGroup>
2121

projects/Benchmarks/ConsumerDispatching/AsyncBasicConsumerFake.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ public Task HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redel
2929
return Task.CompletedTask;
3030
}
3131

32-
void IBasicConsumer.HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey,
33-
in ReadOnlyBasicProperties properties, ReadOnlyMemory<byte> body)
32+
Task IBasicConsumer.HandleBasicDeliverAsync(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey,
33+
ReadOnlyBasicProperties properties, ReadOnlyMemory<byte> body)
3434
{
3535
if (Interlocked.Increment(ref _current) == Count)
3636
{
3737
_current = 0;
3838
_autoResetEvent.Set();
3939
}
40+
return Task.CompletedTask;
4041
}
4142

4243
public Task HandleBasicCancel(string consumerTag) => Task.CompletedTask;

projects/Benchmarks/Networking/Networking_BasicDeliver_Commons.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public class Networking_BasicDeliver_Commons
1212
public static async Task Publish_Hello_World(IConnection connection, uint messageCount, byte[] body)
1313
{
1414
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
15-
using (var channel = connection.CreateChannel())
15+
using (IChannel channel = await connection.CreateChannelAsync())
1616
{
17-
var queue = channel.QueueDeclare();
18-
var consumed = 0;
17+
QueueDeclareOk queue = await channel.QueueDeclareAsync();
18+
int consumed = 0;
1919
var consumer = new EventingBasicConsumer(channel);
2020
consumer.Received += (s, args) =>
2121
{
@@ -24,14 +24,15 @@ public static async Task Publish_Hello_World(IConnection connection, uint messag
2424
tcs.SetResult(true);
2525
}
2626
};
27-
channel.BasicConsume(queue.QueueName, true, consumer);
27+
await channel.BasicConsumeAsync(queue.QueueName, true, consumer);
2828

2929
for (int i = 0; i < messageCount; i++)
3030
{
31-
channel.BasicPublish("", queue.QueueName, body);
31+
await channel.BasicPublishAsync("", queue.QueueName, body);
3232
}
3333

3434
await tcs.Task;
35+
await channel.CloseAsync();
3536
}
3637
}
3738
}

projects/Benchmarks/Networking/Networking_BasicDeliver_ConnectionChurn.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void GlobalCleanup()
3030
public async Task Publish_Hello_World()
3131
{
3232
var cf = new ConnectionFactory { ConsumerDispatchConcurrency = 2 };
33-
using (var connection = cf.CreateConnection())
33+
using (IConnection connection = await cf.CreateConnectionAsync())
3434
{
3535
await Publish_Hello_World(connection);
3636
}

projects/Benchmarks/Networking/Networking_BasicDeliver_LongLivedConnection.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public void GlobalSetup()
2121
_container = RabbitMQBroker.Start();
2222

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

2728
[GlobalCleanup]

projects/RabbitMQ.Client.OAuth2/OAuth2Client.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,22 @@
3434
using System.Net.Http;
3535
using System.Net.Http.Headers;
3636
using System.Net.Http.Json;
37-
using System.Text.Json.Serialization;
3837
using System.Threading.Tasks;
3938

4039
namespace RabbitMQ.Client.OAuth2
4140
{
4241
public interface IOAuth2Client
4342
{
44-
public IToken RequestToken();
45-
public IToken RefreshToken(IToken token);
43+
IToken RequestToken();
44+
IToken RefreshToken(IToken token);
4645
}
4746

4847
public interface IToken
4948
{
50-
public string AccessToken { get; }
51-
public string RefreshToken { get; }
52-
public TimeSpan ExpiresIn { get; }
53-
public bool hasExpired { get; }
49+
string AccessToken { get; }
50+
string RefreshToken { get; }
51+
TimeSpan ExpiresIn { get; }
52+
bool hasExpired { get; }
5453
}
5554

5655
public class Token : IToken

projects/RabbitMQ.Client.OAuth2/RabbitMQ.Client.OAuth2.csproj

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@
2525
<MinVerVerbosity>minimal</MinVerVerbosity>
2626
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2727
<PackageOutputPath>../../packages</PackageOutputPath>
28-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
29-
<LangVersion>latest</LangVersion>
30-
<ReleaseVersion>7.0</ReleaseVersion>
3128
<PackageReadmeFile>README.md</PackageReadmeFile>
29+
<LangVersion>7.3</LangVersion>
3230
</PropertyGroup>
3331

3432
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
@@ -58,7 +56,7 @@
5856
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
5957
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="all" />
6058
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
61-
<PackageReference Include="System.Text.Json" Version="8.0.0" />
59+
<PackageReference Include="System.Text.Json" Version="8.0.1" />
6260
</ItemGroup>
6361

6462
<ItemGroup>

0 commit comments

Comments
 (0)