refactor(queue): support multiple handlers per queue#1512
refactor(queue): support multiple handlers per queue#1512william-p wants to merge 1 commit intoapache:devfrom
Conversation
|
Using multiple handlers seems like a sound design approach. Perhaps you could elaborate on specific use cases, as currently the entire system typically only registers handlers once—scenarios requiring multiple registrations haven't yet arisen. |
|
Today each queue has a single consumer (e.g. only the badge system listens to the event queue), but the event queue is fed by ~15 call sites across the codebase (question/answer/comment CRUD, votes, user updates…). This makes it a natural event bus that additional consumers — audit logging, search reindexing, cache invalidation, analytics — should be able to hook into without replacing the existing handler. The goal of this PR is to add custom event handler. The same applies to the notification and activity queues. Generalizing to multi-handler removes this limitation with minimal changes. |
This PR refactors the internal message queue to support registering multiple handlers per queue instead of a single one.
Previously, calling RegisterHandler would overwrite the existing handler. Now, each call appends to a list of handlers, and all registered handlers are invoked for every message.
[nb: I am not a Go developer but I have (tried) to intelligently use AI to help me]