WIP: PoC Decouple domains with Gitlab::EventPublisher
TODO
-
create issue describing the problem to solve -
create specs
Problem
GitLab-Rails codebase presents domain models that are highly coupled with each other. There are a number of initiatives that focus on decoupling domains within the codebase.
One aspect of this coupling is managing side-effects when a particular event happens. Currently when an event E
occurs in a component A
, the side effects are managed by A
which couples it to B
if this must react to E
. Vice-versa, when B
generates an event that causes A
's state to change, it's B
that invokes directly the status change in A
.
This method may make sense when A
and B
are strictly coupled and operate in the same bounded context. If this is not the case this contributes to raise the complexity of the code.
What does this MR do?
This is a PoC that attempts to define a simple publish-subscribe mechanism to decouple domains using Event-driven Architecture.
To do that we leverage our existing infrastructure using Sidekiq workers and provide a way to define events and register listeners to them.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team