| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using System.ComponentModel; |
| | | 6 | | using System.Net; |
| | | 7 | | using Azure.Core; |
| | | 8 | | using Azure.Messaging.ServiceBus.Core; |
| | | 9 | | using Azure.Messaging.ServiceBus.Plugins; |
| | | 10 | | |
| | | 11 | | namespace Azure.Messaging.ServiceBus |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// The set of options that can be specified when creating an <see cref="ServiceBusConnection" /> |
| | | 15 | | /// to configure its behavior. |
| | | 16 | | /// </summary> |
| | | 17 | | /// |
| | | 18 | | public class ServiceBusClientOptions |
| | | 19 | | { |
| | 132 | 20 | | private ServiceBusRetryOptions _retryOptions = new ServiceBusRetryOptions(); |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// The type of protocol and transport that will be used for communicating with the Service Bus |
| | | 24 | | /// service. |
| | | 25 | | /// </summary> |
| | | 26 | | /// |
| | 366 | 27 | | public ServiceBusTransportType TransportType { get; set; } = ServiceBusTransportType.AmqpTcp; |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// The proxy to use for communication over web sockets. |
| | | 31 | | /// </summary> |
| | | 32 | | /// |
| | | 33 | | /// <remarks> |
| | | 34 | | /// A proxy cannot be used for communication over TCP; if web sockets are not in |
| | | 35 | | /// use, specifying a proxy is an invalid option. |
| | | 36 | | /// </remarks> |
| | | 37 | | /// |
| | 236 | 38 | | public IWebProxy Proxy { get; set; } = null; |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// The set of options to use for determining whether a failed operation should be retried and, |
| | | 42 | | /// if so, the amount of time to wait between retry attempts. These options also control the |
| | | 43 | | /// amount of time allowed for receiving messages and other interactions with the Service Bus service. |
| | | 44 | | /// </summary> |
| | | 45 | | public ServiceBusRetryOptions RetryOptions |
| | | 46 | | { |
| | 102 | 47 | | get => _retryOptions; |
| | | 48 | | set |
| | | 49 | | { |
| | 60 | 50 | | Argument.AssertNotNull(value, nameof(RetryOptions)); |
| | 60 | 51 | | _retryOptions = value; |
| | 60 | 52 | | } |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// The list of plugins for the client. |
| | | 57 | | /// </summary> |
| | 294 | 58 | | internal List<ServiceBusPlugin> Plugins { get; set; } = new List<ServiceBusPlugin>(); |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// Register a plugin to be used to alter |
| | | 62 | | /// incoming/outgoing messages. |
| | | 63 | | /// </summary> |
| | | 64 | | /// <param name="plugin">The plugin instance to register.</param> |
| | | 65 | | internal void AddPlugin(ServiceBusPlugin plugin) |
| | | 66 | | { |
| | 0 | 67 | | Argument.AssertNotNull(plugin, nameof(plugin)); |
| | 0 | 68 | | Plugins.Add(plugin); |
| | 0 | 69 | | } |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Determines whether the specified <see cref="System.Object" /> is equal to this instance. |
| | | 73 | | /// </summary> |
| | | 74 | | /// |
| | | 75 | | /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> |
| | | 76 | | /// |
| | | 77 | | /// <returns><c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c> |
| | | 78 | | /// |
| | | 79 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 80 | | public override bool Equals(object obj) => base.Equals(obj); |
| | | 81 | | |
| | | 82 | | /// <summary> |
| | | 83 | | /// Returns a hash code for this instance. |
| | | 84 | | /// </summary> |
| | | 85 | | /// |
| | | 86 | | /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a ha |
| | | 87 | | /// |
| | | 88 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 89 | | public override int GetHashCode() => base.GetHashCode(); |
| | | 90 | | |
| | | 91 | | /// <summary> |
| | | 92 | | /// Converts the instance to string representation. |
| | | 93 | | /// </summary> |
| | | 94 | | /// |
| | | 95 | | /// <returns>A <see cref="System.String" /> that represents this instance.</returns> |
| | | 96 | | /// |
| | | 97 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 4 | 98 | | public override string ToString() => base.ToString(); |
| | | 99 | | |
| | | 100 | | /// <summary> |
| | | 101 | | /// Creates a new copy of the current <see cref="ServiceBusClientOptions" />, cloning its attributes into a ne |
| | | 102 | | /// </summary> |
| | | 103 | | /// /// |
| | | 104 | | /// <returns>A new copy of <see cref="ServiceBusClientOptions" />.</returns> |
| | | 105 | | /// |
| | | 106 | | internal ServiceBusClientOptions Clone() => |
| | 60 | 107 | | new ServiceBusClientOptions |
| | 60 | 108 | | { |
| | 60 | 109 | | TransportType = TransportType, |
| | 60 | 110 | | Proxy = Proxy, |
| | 60 | 111 | | RetryOptions = RetryOptions.Clone(), |
| | 60 | 112 | | Plugins = new List<ServiceBusPlugin>(Plugins) |
| | 60 | 113 | | }; |
| | | 114 | | } |
| | | 115 | | } |