Skip to content
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

Updated interface to include Async events. #353

Merged
merged 4 commits 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
10 changes: 10 additions & 0 deletions src/NATS.Client.Core/INatsConnection.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
using System.Diagnostics.CodeAnalysis;

namespace NATS.Client.Core;

public interface INatsConnection : IAsyncDisposable
{
event AsyncEventHandler<NatsEventArgs>? ConnectionDisconnected;

event AsyncEventHandler<NatsEventArgs>? ConnectionOpened;

event AsyncEventHandler<NatsEventArgs>? ReconnectFailed;

event AsyncEventHandler<NatsMessageDroppedEventArgs>? MessageDropped;

INatsServerInfo? ServerInfo { get; }

NatsOpts Opts { get; }
Expand Down
4 changes: 0 additions & 4 deletions tests/NATS.Client.Core.Tests/NatsConnectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ public void InterfaceShouldHaveSamePublicPropertiesEventsAndMethodAsClass()
{
var name = classInfo.Name;

// TODO: enable this check when we have events pulled up to the interface
if (Regex.IsMatch(name, @"add_|remove_"))
continue;

interfaceMethods.Select(m => m.Name).Should().Contain(name);
}
}
Expand Down
29 changes: 26 additions & 3 deletions tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NATS.Client.Core.Tests;
using NATS.Client.JetStream.Models;

namespace NATS.Client.JetStream.Tests;

Expand Down Expand Up @@ -83,6 +82,14 @@

public class MockConnection : INatsConnection
{
public event AsyncEventHandler<NatsEventArgs>? ConnectionDisconnected;

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

Check warning on line 85 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionDisconnected' is never used

public event AsyncEventHandler<NatsEventArgs>? ConnectionOpened;

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

Check warning on line 87 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ConnectionOpened' is never used

public event AsyncEventHandler<NatsEventArgs>? ReconnectFailed;

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

Check warning on line 89 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.ReconnectFailed' is never used

public event AsyncEventHandler<NatsMessageDroppedEventArgs>? MessageDropped;

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (latest)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / memory test (main)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (main)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (latest)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

Check warning on line 91 in tests/NATS.Client.JetStream.Tests/NatsJsContextFactoryTest.cs

View workflow job for this annotation

GitHub Actions / dotnet (release/v2.9.23)

The event 'NatsJSContextFactoryTest.MockConnection.MessageDropped' is never used

public INatsServerInfo? ServerInfo { get; } = null;

public NatsOpts Opts { get; } = new();
Expand All @@ -103,10 +110,26 @@

public string NewInbox() => throw new NotImplementedException();

public ValueTask<NatsMsg<TReply>> RequestAsync<TRequest, TReply>(string subject, TRequest? data, NatsHeaders? headers = default, INatsSerialize<TRequest>? requestSerializer = default, INatsDeserialize<TReply>? replySerializer = default, NatsPubOpts? requestOpts = default, NatsSubOpts? replyOpts = default, CancellationToken cancellationToken = default)
public ValueTask<NatsMsg<TReply>> RequestAsync<TRequest, TReply>(
string subject,
TRequest? data,
NatsHeaders? headers = default,
INatsSerialize<TRequest>? requestSerializer = default,
INatsDeserialize<TReply>? replySerializer = default,
NatsPubOpts? requestOpts = default,
NatsSubOpts? replyOpts = default,
CancellationToken cancellationToken = default)
=> throw new NotImplementedException();

public IAsyncEnumerable<NatsMsg<TReply>> RequestManyAsync<TRequest, TReply>(string subject, TRequest? data, NatsHeaders? headers = default, INatsSerialize<TRequest>? requestSerializer = default, INatsDeserialize<TReply>? replySerializer = default, NatsPubOpts? requestOpts = default, NatsSubOpts? replyOpts = default, CancellationToken cancellationToken = default)
public IAsyncEnumerable<NatsMsg<TReply>> RequestManyAsync<TRequest, TReply>(
string subject,
TRequest? data,
NatsHeaders? headers = default,
INatsSerialize<TRequest>? requestSerializer = default,
INatsDeserialize<TReply>? replySerializer = default,
NatsPubOpts? requestOpts = default,
NatsSubOpts? replyOpts = default,
CancellationToken cancellationToken = default)
=> throw new NotImplementedException();

public ValueTask ConnectAsync() => throw new NotImplementedException();
Expand Down
Loading