Skip to content

Remove synchronous API #1473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if ($RunTests)
foreach ($csproj_file in $unit_csproj_file, $integration_csproj_file, $async_integration_csproj_file, $sequential_integration_csproj_file)
{
Write-Host "[INFO] running Unit / Integration tests from '$csproj_file' (all frameworks)" -ForegroundColor "Magenta"
dotnet test $csproj_file --no-restore --no-build --logger "console;verbosity=detailed"
dotnet test $csproj_file --environment 'RABBITMQ_LONG_RUNNING_TESTS=true' --no-restore --no-build --logger "console;verbosity=detailed"
if ($LASTEXITCODE -ne 0)
{
Write-Host "[ERROR] tests errored, exiting" -Foreground "Red"
Expand Down
2 changes: 1 addition & 1 deletion projects/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.11" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ public Task HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redel
return Task.CompletedTask;
}

void IBasicConsumer.HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey,
in ReadOnlyBasicProperties properties, ReadOnlyMemory<byte> body)
Task IBasicConsumer.HandleBasicDeliverAsync(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey,
ReadOnlyBasicProperties properties, ReadOnlyMemory<byte> body)
{
if (Interlocked.Increment(ref _current) == Count)
{
_current = 0;
_autoResetEvent.Set();
}
return Task.CompletedTask;
}

public Task HandleBasicCancel(string consumerTag) => Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class Networking_BasicDeliver_Commons
public static async Task Publish_Hello_World(IConnection connection, uint messageCount, byte[] body)
{
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
using (var channel = connection.CreateChannel())
using (IChannel channel = await connection.CreateChannelAsync())
{
var queue = channel.QueueDeclare();
var consumed = 0;
QueueDeclareOk queue = await channel.QueueDeclareAsync();
int consumed = 0;
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (s, args) =>
{
Expand All @@ -24,14 +24,15 @@ public static async Task Publish_Hello_World(IConnection connection, uint messag
tcs.SetResult(true);
}
};
channel.BasicConsume(queue.QueueName, true, consumer);
await channel.BasicConsumeAsync(queue.QueueName, true, consumer);

for (int i = 0; i < messageCount; i++)
{
channel.BasicPublish("", queue.QueueName, body);
await channel.BasicPublishAsync("", queue.QueueName, body);
}

await tcs.Task;
await channel.CloseAsync();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void GlobalCleanup()
public async Task Publish_Hello_World()
{
var cf = new ConnectionFactory { ConsumerDispatchConcurrency = 2 };
using (var connection = cf.CreateConnection())
using (IConnection connection = await cf.CreateConnectionAsync())
{
await Publish_Hello_World(connection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public void GlobalSetup()
_container = RabbitMQBroker.Start();

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

[GlobalCleanup]
Expand Down
13 changes: 6 additions & 7 deletions projects/RabbitMQ.Client.OAuth2/OAuth2Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,22 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace RabbitMQ.Client.OAuth2
{
public interface IOAuth2Client
{
public IToken RequestToken();
public IToken RefreshToken(IToken token);
IToken RequestToken();
IToken RefreshToken(IToken token);
}

public interface IToken
{
public string AccessToken { get; }
public string RefreshToken { get; }
public TimeSpan ExpiresIn { get; }
public bool hasExpired { get; }
string AccessToken { get; }
string RefreshToken { get; }
TimeSpan ExpiresIn { get; }
bool hasExpired { get; }
}

public class Token : IToken
Expand Down
6 changes: 2 additions & 4 deletions projects/RabbitMQ.Client.OAuth2/RabbitMQ.Client.OAuth2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
<MinVerVerbosity>minimal</MinVerVerbosity>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>../../packages</PackageOutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<ReleaseVersion>7.0</ReleaseVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
Expand Down Expand Up @@ -58,7 +56,7 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading