Skip to content
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

refactor: InstanceStatus out of DB Watcher #32371

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented May 6, 2024

As per the updates mentioned in PROJ-7 SCA-9 and ADR #74, this pull request focuses on relocating InstanceStatus entity out of DB Watcher service.

Quick context to public readers

In essence, this modification empowers RocketChat's app to directly call listeners through the api.broadcast global function, eliminating the reliance on MongoDB Change Stream data propagation

Why is this beneficial? It provides better control over notifying users by enabling more precise use-case management. Unlike Change Streams, which notify every action on Mongo's documents and sometimes might result in unnecessary duplicate notifications. Moreover, it contributes to the future removal of the DB Watcher deployment, thereby optimizing resource utilization.

Proposed changes

Key changes include:

  • Conditionally incorporating InstanceStatus entity import within DB watchers on application startup based on the dbWatchersDisabled flag.
  • Enabling support for the following use cases to directly trigger watch.instanceStatus listener event, subject to the dbWatchersDisabled flag.

Changes were made within the instance-status package to cater to its use case, thereby avoiding the addition of a new package containing broadcast helpers (located at app/lib/server/lib/notifyListener.ts) - similar to the approach taken with other entities recently moved out of the database watcher.

Updated use cases.
Use Case Route/Trigger Notes
registerService When setting up a new service
unregisterService When a specific service shuts down
updateConnections Triggered every 30 seconds or upon receiving an event Updates the number of connections

Steps to test or reproduce

  1. Start RocketChat's application with the DISABLE_DB_WATCHERS flag set to true.
  2. Initiate RocketChat Community Edition or perform new services setup on Enterprise Edition to witness the registration of one service.

Further comments

To maintain consistency and avoid potential regressions, event names and signatures have been kept unchanged on both the client and app sides. This decision streamlines efforts and mitigates the risk of unintended consequences.

Copy link
Contributor

dionisio-bot bot commented May 6, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented May 6, 2024

⚠️ No Changeset found

Latest commit: f353f86

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented May 6, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 55.59%. Comparing base (190d1de) to head (e035be8).
Report is 2 commits behind head on develop.

❗ Current head e035be8 differs from pull request most recent head f353f86. Consider uploading reports for the commit f353f86 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #32371      +/-   ##
===========================================
- Coverage    55.59%   55.59%   -0.01%     
===========================================
  Files         2408     2404       -4     
  Lines        52997    52954      -43     
  Branches     10894    10889       -5     
===========================================
- Hits         29465    29439      -26     
+ Misses       20918    20909       -9     
+ Partials      2614     2606       -8     
Flag Coverage Δ
e2e 55.02% <ø> (-0.04%) ⬇️
unit 73.09% <14.28%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ricardogarim ricardogarim force-pushed the refactor/instance-status-model-out-of-db-watcher branch 2 times, most recently from 7e43624 to c813484 Compare May 10, 2024 03:02
@ricardogarim ricardogarim marked this pull request as ready for review May 10, 2024 12:12
@ricardogarim ricardogarim requested a review from a team as a code owner May 10, 2024 12:12
@ricardogarim ricardogarim force-pushed the refactor/instance-status-model-out-of-db-watcher branch from b77526a to e035be8 Compare May 14, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants