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

Add Connected/Disconnected events #28379

Closed
wants to merge 3 commits into from

Conversation

JoshLove-msft
Copy link
Member

Alternative approach to address #8561

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

API change check for Azure.Messaging.ServiceBus

API changes have been detected in Azure.Messaging.ServiceBus. You can review API changes here

@@ -69,7 +66,7 @@ internal class AmqpClient : TransportClient
///
/// <param name="host">The fully qualified host name for the Service Bus namespace. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
/// <param name="credential">The Azure managed identity credential to use for authorization. Access controls may be specified by the Service Bus namespace or the requested Service Bus entity, depending on Azure configuration.</param>
/// <param name="options">A set of options to apply when configuring the client.</param>
/// <param name="client">A set of options to apply when configuring the client.</param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Comment is no longer accurate.

/// <summary>
/// An event that can be subscribed to for notification when the client connects to the service.
/// </summary>
#pragma warning disable AZC0002
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Comments for what these warnings are would be helpful.

public virtual bool IsConnected => Connection.IsConnected;

/// <summary>
///
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Needs content.

/// <summary>
/// The proxy being used when communicating with the service.
/// </summary>
public IWebProxy Proxy { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxy and TransportType are interesting additions. What's the scenario where they'd be useful? I'd see the client identifier being more helpful to differentiate between multiple instances.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I considered that but was thinking it might be better to wait until we actually expose Identifier on the client. Mostly, I just wanted to add the event args type now so that we can evolve it in the future.

/// automatically on the next operation. As such, it is not recommended that this property is checked before performing operations with the <see cref="ServiceBusClient"/>
/// or any of the other Service Bus types. This property should be used only for diagnostic information.
/// </summary>
public virtual bool IsConnected => Connection.IsConnected;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also consider noting that this property does not indicate that read/publish operations are actively taking place.

/// <remarks>
/// If the connection string is copied from the Service Bus entity itself, it will contain the name of the desired Service Bus entity,
/// and can be used directly without passing the name="entityName" />. The name of the Service Bus entity should be
/// passed only once, either as part of the connection string or separately.
/// </remarks>
internal ServiceBusConnection(
string connectionString,
ServiceBusClientOptions options)
ServiceBusClient client)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same hesitation here that I mentioned in the transport client; this changes the flow of dependencies from a single direction into circular. Have we considered surfacing the connected/disconnected events from the transport client through the connection?

@@ -473,11 +473,6 @@ public void MetricsPropertyDoesNotThrowWhenEnabled()
///
public class ReadableOptionsMock : ServiceBusClient
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider some unit tests for the handlers here, since we can fully control when they fire and what args they emit.

{
WasCloseCalled = true;
return Task.CompletedTask;
await DisconnectedAsync(new ServiceBusConnectionEventArgs(ServiceEndpoint.Host, ServiceBusTransportType.AmqpTcp, null));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update to add explicit tests for these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants