You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bridge: reduce duplicate consumer code as much as possible (#926)
Adds wrapper types around the backend-specific types we get from
generic-queue.
## Motivation
Adding new backends to the consumer bridge plugin today is a bit of a
chore, encouraging parts of the ack/nack and consumer loop flow to be
duplicated. The generics exposed in the signatures of items from
`generic-queue` tend to make code reuse tricky.
## Solution
This is mostly focused on moving the decision-making bits of the flow up
to the trait's default implementation for methods like `receive` and
`process` since these were essentially duplicate from backend to
backend.
New wrapper types are used to hide/erase the distinct backend typing
from the consumer flow.
Additionally, the code related to each backend has been relegated to a
dedicated module (which should help when adding new backends since you
can copy the module entirely as a starting point).
More refactoring could be done, perhaps adding `enum_dispatch` to reduce
runtime cost and improve the layout of the code generally, but even
without this seems like a good first step.
0 commit comments