/// <summary> /// Initializes a new instance of the <see cref="AmqpClient"/> class. /// </summary> /// /// <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> /// /// <remarks> /// As an internal type, this class performs only basic sanity checks against its arguments. It /// is assumed that callers are trusted and have performed deep validation. /// /// Any parameters passed are assumed to be owned by this instance and safe to mutate or dispose; /// creation of clones or otherwise protecting the parameters is assumed to be the purview of the /// caller. /// </remarks> /// internal AmqpClient( string host, ServiceBusTokenCredential credential, ServiceBusClientOptions options) { Argument.AssertNotNullOrEmpty(host, nameof(host)); Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(options, nameof(options)); ServiceEndpoint = new UriBuilder { Scheme = options.TransportType.GetUriScheme(), Host = host }.Uri; Credential = credential; if (options.EnableTransportMetrics) { TransportMetrics = new ServiceBusTransportMetrics(); } ConnectionScope = new AmqpConnectionScope( ServiceEndpoint, credential, options.TransportType, options.WebProxy, options.EnableCrossEntityTransactions, options.RetryOptions.TryTimeout, TransportMetrics); }
public void CloneCopiesAllProperties() { var now = DateTimeOffset.UtcNow; var yesterday = now.Subtract(TimeSpan.FromDays(1)); var tomorrow = now.Add(TimeSpan.FromDays(1)); var metrics = new ServiceBusTransportMetrics { LastHeartBeat = now, LastConnectionOpen = yesterday, LastConnectionClose = tomorrow, }; var cloned = metrics.Clone(); Assert.AreEqual(metrics.LastHeartBeat, cloned.LastHeartBeat); Assert.AreEqual(metrics.LastConnectionOpen, cloned.LastConnectionOpen); Assert.AreEqual(metrics.LastConnectionClose, cloned.LastConnectionClose); }
public AmqpUsageMeter(ServiceBusTransportMetrics metrics) { _metrics = metrics; }