EasyNetQ icon indicating copy to clipboard operation
EasyNetQ copied to clipboard

Replacement for IsConnected/ConnectAsync, these methods are misleading

Open Pliner opened this issue 2 years ago • 2 comments

Fixes #1513, Related to #1650, #1433, #1462, #1301, #1147.

There were a lot of complaints for IsConnected behaviour after we added multiple connections under the hood for producer and consumer respectively in #1273. Moreover, laziness of connections made the situation even worse.

I believe that we should remain connections lazy, so providing API to inspect connection status precisely per connection type (instead of global IsConnected property) might reduce awkwardness of the API.

The PR introduces several new methods to IAdvancedBus:

  1. PersistentConnectionStatus GetConnectionStatus(PersistentConnectionType type)
  2. Task EnsureConnectedAsync(PersistentConnectionType type, CancellationToken cancellationToken = default);

EnsureConnectedAsync fixes a small ambiguity of ConnectAsync: ConnectAsync doesn't not throw when a connection was established, but then disrupted.

Pliner avatar Aug 13 '23 13:08 Pliner

@zidad @micdenny Could you take a look on it?

Pliner avatar Aug 27 '23 09:08 Pliner

@zidad @micdenny Could you take a look on it?

Feel free to review/comment later before v8 release.

Pliner avatar Sep 10 '23 09:09 Pliner