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

#686: Remove unused code and make some methods private #828

Merged
merged 1 commit into from
Feb 25, 2025
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
492 changes: 7 additions & 485 deletions src/Common/Helpers/ServiceBusHelper.cs

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions src/Common/WindowsAzure/IServiceBusConsumerGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ internal interface IServiceBusConsumerGroup : IServiceBusEntity
ConsumerGroupDescription CreateConsumerGroup(ConsumerGroupDescription description);

void DeleteConsumerGroup(ConsumerGroupDescription consumerGroupDescription);

void DeleteConsumerGroup(string eventHubName, string name);


void DeleteConsumerGroups(string eventHubName, IEnumerable<string> consumerGroups);

ConsumerGroupDescription GetConsumerGroup(string eventHubPath, string name);

IEnumerable<ConsumerGroupDescription> GetConsumerGroups(EventHubDescription description);


IEnumerable<ConsumerGroupDescription> GetConsumerGroups(string path);

Uri GetConsumerGroupUri(string eventHubName, string consumerGroupPath);
Expand Down
9 changes: 2 additions & 7 deletions src/Common/WindowsAzure/IServiceBusEventHub.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Messaging;

namespace ServiceBusExplorer.WindowsAzure
Expand All @@ -10,15 +9,11 @@ internal interface IServiceBusEventHub : IServiceBusEntity
EventHubDescription CreateEventHub(EventHubDescription description);

void DeleteEventHub(EventHubDescription eventHubDescription);

void DeleteEventHub(string path);


void DeleteEventHubs(IEnumerable<string> eventHubs);

EventHubDescription GetEventHub(string path);

Task<IEnumerable<EventHubDescription>> GetEventHubs(int timeoutInSeconds);


Uri GetEventHubUri(string eventHubPath);

EventHubDescription UpdateEventHub(EventHubDescription description);
Expand Down
8 changes: 2 additions & 6 deletions src/Common/WindowsAzure/IServiceBusNotificationHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ internal interface IServiceBusNotificationHub : IServiceBusEntity
NotificationHubDescription CreateNotificationHub(NotificationHubDescription description);

Task DeleteNotificationHub(NotificationHubDescription notificationHubDescription);

Task DeleteNotificationHub(string path);


Task DeleteNotificationHubs(IEnumerable<string> notificationHubs);

NotificationHubDescription GetNotificationHub(string path);

IEnumerable<NotificationHubDescription> GetNotificationHubs(int timeoutInSeconds);


Uri GetNotificationHubUri(string notificationHubPath);

NotificationHubDescription UpdateNotificationHub(NotificationHubDescription description);
Expand Down
12 changes: 2 additions & 10 deletions src/Common/WindowsAzure/IServiceBusPartition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@
namespace ServiceBusExplorer.WindowsAzure
{
internal interface IServiceBusPartition : IServiceBusEntity
{
PartitionDescription GetPartition(PartitionDescription partitionDescription);

{
PartitionDescription GetPartition(string path, string consumerGroupName, string name);

IEnumerable<PartitionDescription> GetPartitions(EventHubDescription description);

IEnumerable<PartitionDescription> GetPartitions(EventHubDescription description, string consumerGroupName);

IEnumerable<PartitionDescription> GetPartitions(string path);


IEnumerable<PartitionDescription> GetPartitions(string path, string consumerGroupName);

Uri GetPartitionUri(string eventHubName, string consumerGroupName, string partitionId);
Expand Down
5 changes: 0 additions & 5 deletions src/Common/WindowsAzure/IServiceBusQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Messaging;
using ServiceBusExplorer.Helpers;

namespace ServiceBusExplorer.WindowsAzure
{
internal interface IServiceBusQueue : IServiceBusEntity
{
QueueDescription CreateQueue(QueueDescription description);

QueueDescription CreateQueue(string path);

Task DeleteQueue(QueueDescription queueDescription);

Task DeleteQueue(string path);

Task DeleteQueues(IEnumerable<string> queues);

QueueDescription GetQueue(string path);
Expand Down
4 changes: 1 addition & 3 deletions src/Common/WindowsAzure/IServiceBusRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ internal interface IServiceBusRule : IServiceBusEntity
IEnumerable<RuleDescription> GetRules(SubscriptionDescription subscription);

void RemoveRule(SubscriptionDescription subscriptionDescription, RuleDescription rule);

void RemoveRule(SubscriptionDescription subscriptionDescription, string name);


void RemoveRules(IEnumerable<RuleWrapper> wrappers);
}
}
6 changes: 0 additions & 6 deletions src/Common/WindowsAzure/IServiceBusSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ internal interface IServiceBusSubscription : IServiceBusEntity

SubscriptionDescription CreateSubscription(TopicDescription topicDescription, SubscriptionDescription subscriptionDescription, RuleDescription ruleDescription);

void DeleteSubscription(string topicPath, string name);

Task DeleteSubscription(SubscriptionDescription subscriptionDescription);

Task DeleteSubscriptions(IEnumerable<SubscriptionDescription> subscriptionDescriptions);
Expand All @@ -23,10 +21,6 @@ internal interface IServiceBusSubscription : IServiceBusEntity

IEnumerable<SubscriptionDescription> GetSubscriptions(string topicPath);

IEnumerable<SubscriptionDescription> GetSubscriptions(string topicPath, string filter);

IEnumerable<SubscriptionDescription> GetSubscriptions(TopicDescription topic);

IEnumerable<SubscriptionDescription> GetSubscriptions(TopicDescription topic, string filter);

Uri GetSubscriptionUri(string topicPath, string name);
Expand Down
5 changes: 0 additions & 5 deletions src/Common/WindowsAzure/IServiceBusTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Messaging;
using ServiceBusExplorer.Helpers;

namespace ServiceBusExplorer.WindowsAzure
{
internal interface IServiceBusTopic : IServiceBusEntity
{
TopicDescription CreateTopic(string path);

TopicDescription CreateTopic(TopicDescription topicDescription);

Task DeleteTopic(string path);

Task DeleteTopic(TopicDescription topic);

Task DeleteTopics(IEnumerable<string> topics);
Expand Down
64 changes: 19 additions & 45 deletions src/Common/WindowsAzure/ServiceBusConsumerGroup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using ServiceBusExplorer.Enums;
Expand All @@ -13,7 +10,6 @@ namespace ServiceBusExplorer.WindowsAzure
{
internal class ServiceBusConsumerGroup : ServiceBusEntity, IServiceBusConsumerGroup
{
private const string EventHubDescriptionCannotBeNull = "The event hub description argument cannot be null.";
private const string ConsumerGroupDescriptionCannotBeNull = "The consumer group description argument cannot be null.";
private const string ConsumerGroupCreated = "The consumer group {0} has been successfully created.";
private const string ConsumerGroupDeleted = "The consumer group {0} has been successfully deleted.";
Expand Down Expand Up @@ -68,24 +64,6 @@ public IEnumerable<ConsumerGroupDescription> GetConsumerGroups(string path)
throw new ApplicationException(ServiceBusIsDisconnected);
}

/// <summary>
/// Retrieves the collection of consumer groups of the event hub passed as a parameter.
/// </summary>
/// <param name="description">A event hub belonging to the current service namespace base.</param>
/// <returns>Returns an IEnumerable<SubscriptionDescription/> collection of consumer groups attached to the event hub passed as a parameter.</returns>
public IEnumerable<ConsumerGroupDescription> GetConsumerGroups(EventHubDescription description)
{
if (description == null)
{
throw new ArgumentException(EventHubDescriptionCannotBeNull);
}
if (NamespaceManager != null)
{
return RetryHelper.RetryFunc(() => NamespaceManager.GetConsumerGroups(description.Path), WriteToLog);
}
throw new ApplicationException(ServiceBusIsDisconnected);
}

/// <summary>
/// Creates a new consumer group in the service namespace with the given name.
/// </summary>
Expand All @@ -107,29 +85,6 @@ public ConsumerGroupDescription CreateConsumerGroup(ConsumerGroupDescription des
throw new ApplicationException(ServiceBusIsDisconnected);
}

/// <summary>
/// Deletes the consumer group described by the relative name of the service namespace base address.
/// </summary>
/// <param name="eventHubName">Name of the event hub.</param>
/// <param name="name">Name of the consumer group.</param>
public void DeleteConsumerGroup(string eventHubName, string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException(PathCannotBeNull);
}
if (NamespaceManager != null)
{
RetryHelper.RetryAction(() => NamespaceManager.DeleteConsumerGroup(eventHubName, name), WriteToLog);
Log(string.Format(CultureInfo.CurrentCulture, ConsumerGroupDeleted, name));
OnDeleted(new ConsumerGroupDescription(eventHubName, name));
}
else
{
throw new ApplicationException(ServiceBusIsDisconnected);
}
}

/// <summary>
/// Deletes the consumer group described by the relative name of the service namespace base address.
/// </summary>
Expand Down Expand Up @@ -200,5 +155,24 @@ public Uri GetConsumerGroupUri(string eventHubName, string consumerGroupPath)
{
return Microsoft.ServiceBus.ServiceBusEnvironment.CreateServiceUri(Scheme, Namespace, string.Concat(servicePath, eventHubName, "/", consumerGroupPath));
}

private void DeleteConsumerGroup(string eventHubName, string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException(PathCannotBeNull);
}
if (NamespaceManager != null)
{
RetryHelper.RetryAction(() => NamespaceManager.DeleteConsumerGroup(eventHubName, name), WriteToLog);
Log(string.Format(CultureInfo.CurrentCulture, ConsumerGroupDeleted, name));
OnDeleted(new ConsumerGroupDescription(eventHubName, name));
}
else
{
throw new ApplicationException(ServiceBusIsDisconnected);
}
}

}
}
68 changes: 19 additions & 49 deletions src/Common/WindowsAzure/ServiceBusEventHub.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using ServiceBusExplorer.Enums;
Expand Down Expand Up @@ -43,32 +42,6 @@ public EventHubDescription GetEventHub(string path)
throw new ApplicationException(ServiceBusIsDisconnected);
}

/// <summary>
/// Retrieves an enumerable collection of all event hubs in the service bus namespace.
/// </summary>
/// <returns>Returns an IEnumerable<EventHubDescription/> collection of all event hubs in the service namespace.
/// Returns an empty collection if no event hub exists in this service namespace.</returns>
public Task<IEnumerable<EventHubDescription>> GetEventHubs(int timeoutInSeconds)
{
if (NamespaceManager != null)
{
var taskList = new List<Task>();
var task = NamespaceManager.GetEventHubsAsync();
taskList.Add(task);
taskList.Add(Task.Delay(TimeSpan.FromSeconds(timeoutInSeconds)));
Task.WaitAny(taskList.ToArray());
if (task.IsCompleted)
{
return task;
}
else
{
throw new TimeoutException();
}
}
throw new ApplicationException(ServiceBusIsDisconnected);
}

/// <summary>
/// Creates a new event hub in the service namespace with the given name.
/// </summary>
Expand All @@ -90,28 +63,6 @@ public EventHubDescription CreateEventHub(EventHubDescription description)
throw new ApplicationException(ServiceBusIsDisconnected);
}

/// <summary>
/// Deletes the event hub described by the relative name of the service namespace base address.
/// </summary>
/// <param name="path">Path of the event hub relative to the service namespace base address.</param>
public void DeleteEventHub(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException(PathCannotBeNull);
}
if (NamespaceManager != null)
{
RetryHelper.RetryAction(() => NamespaceManager.DeleteEventHub(path), WriteToLog);
Log(string.Format(CultureInfo.CurrentCulture, EventHubDeleted, path));
OnDeleted(new ServiceBusHelperEventArgs(path, EntityType.EventHub));
}
else
{
throw new ApplicationException(ServiceBusIsDisconnected);
}
}

/// <summary>
/// Deletes the event hub described by the relative name of the service namespace base address.
/// </summary>
Expand Down Expand Up @@ -180,5 +131,24 @@ public Uri GetEventHubUri(string eventHubPath)
{
return Microsoft.ServiceBus.ServiceBusEnvironment.CreateServiceUri(Scheme, Namespace, string.Concat(servicePath, eventHubPath));
}

private void DeleteEventHub(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException(PathCannotBeNull);
}
if (NamespaceManager != null)
{
RetryHelper.RetryAction(() => NamespaceManager.DeleteEventHub(path), WriteToLog);
Log(string.Format(CultureInfo.CurrentCulture, EventHubDeleted, path));
OnDeleted(new ServiceBusHelperEventArgs(path, EntityType.EventHub));
}
else
{
throw new ApplicationException(ServiceBusIsDisconnected);
}
}

}
}
Loading
Loading