-
Notifications
You must be signed in to change notification settings - Fork 60
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
Move hook domain logic from routes to domain #1774
Conversation
Pull Request Test Coverage Report for Build 10004593065Details
💛 - Coveralls |
this.queueName = this.configurationService.getOrThrow<string>('amqp.queue'); | ||
} | ||
|
||
onModuleInit(): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might face a race condition here: if this onModuleInit
function is executed before CacheHooksService.onModuleinit
, then this.listeners
would be empty, and therefore the first events wouldn't be processed by any listener, right? I don't know if they would be lost as they wouldn't be ACKed but maybe the events processing order is modified. I'd avoid relying on the class instantiation order, but maybe I'm missing something.
What do you think about moving the complete CacheHooksService
implementation to the domain layer instead (including its onEvent
function). To me, it was always a bit weird that this core logic lives in the routes layer so this might be a good opportunity to move it to its own class in the domain and would save us a level of indirection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points, with which I agree with. As of 6271732, I've moved the relevant CacheHooksService
logic to the domain. Please let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Summary
With the forthcoming implementation of notification dispatch according to events, hooks will also trigger enqueuing notifications. This moves the domain-considered logic from
CacheHooksService
to a newHooksRepository
in the domain. There the aforementioned notification-relevant logic will be placed.Changes
CacheHooksService
toHooksRepository