Azure / azure-event-hubs-node

Node client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
MIT License
50 stars 46 forks source link

Refactor common code #121

Closed amarzavery closed 5 years ago

amarzavery commented 6 years ago

Step 1:

What we have currently works fine. However, there is lot of code duplication between EventHubReceiver and EventHubSender. Most of it can be moved up into LinkEntity. LinkEntity should have a protected property named _link which will be of type Link. Today rhea-promise also has code duplication in Sender and Receiver. Common code should be moved to Link. Then the _link will be of type Link.

Since ManagementClient also extends LinkEntity and ManagementClient has a private property reqresLink which is different than Link. Thus it would make sense to have a base class named ClientEntity which has a child class named LinkEntity and may be another child named BidirectionalLinkEntity. EHSender, EHReceiver and ManagementClient can be children of the intermediate parent classes. This would sort of be the right structure of reusing common code.

Step 2: If possible we should try to get as much as possible into amqp-common since ServiceBus and Eventhubs both have lot of common functionality. However this needs to be done carefully since there are some basic differences in the structure of ConnectionContext.

ramya-rao-a commented 5 years ago

@amarzavery Looks like most of what you have described above has already been implemented

Therefore, closing this issue