Refactor common code
amarzavery opened this issue · 1 comments
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.
@amarzavery Looks like most of what you have described above has already been implemented
- We now have a
Link
class in rhea-promise from which is extended bySender
andReceiver
- In EventHubs, both
EventHubSender
andEventHubReceiver
extend fromLinkEntity
ConnectionContextBase
is in amqp-common with common things factored out from Event Hubs and Service Bus.
Therefore, closing this issue