-
Notifications
You must be signed in to change notification settings - Fork 449
chore: make dependencies manager a singleton #4161
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
Conversation
ff716b0
to
2ef9365
Compare
Why do we want it to be a singleton? |
DI is good as well but currently to decouple modules from Tracee we should inject those modules (changing function/method signatures) of all related to it. This demands a clear vision of the relation of the elements. And it also only works if the injected is thread safe what dependencies manager isn't yet. About the coupling of the singleton in tests... We can use methods to control its visibility only for the test build tag. That's a change that I was about to do to this PR, so the Reset function wouldn't be available to production, only in tests. Anyhoo, if you do prefer I can step back, make dependencies manager thread-safe first and in futures PRs:
WDYT? Last note: the main focus on making the transitional objects into singletons is to make the code logic easy in the tidying process, without touching much code. When the objects with relations are moved and tidied, the singleton pattern should be removed leaving the injection to do the job. |
Correction:
As it would be thread safe, all that demands access to it should get a copy from Tracee's. |
If this step is only transitional and the goal is to make the logic easy before removing the singleton, I'm ok with it. |
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.
LGTM, considering #4161 (comment)
This tidies up the dependencies manager by making it a singleton, temporarily. It's a necessary step to decouple the manager from the Tracee object without touching much code, allowing it to be accessed from other parts of the codebase and be detached from other logic. It introduces an also temporary ResetManagerFromTests() to reset the manager state between tests. When elements are decoupled and redesign, the manager will not be a singleton anymore, but it will be accessed via dependency injection. NOTE: It continues being not thread-safe. This will be addressed in a future PR.
2ef9365
to
3cd64e9
Compare
3cd64e9
to
83c39cf
Compare
1. Explain what the PR does
83c39cf chore: mv dependencies tests to same pkg
5b6c9fc chore: make dependencies manager a singleton (temp)
5b6c9fc chore: make dependencies manager a singleton (temp)
2. Explain how to test it
3. Other comments