Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

chore: makes instance-status works along with Moleculer lifecyle

Open ricardogarim opened this issue 1 year ago • 4 comments

Proposed changes (including videos or screenshots)

This PR removes the use of MongoDB Change Streams on instance-status package. The removal of Change Stream items is part of an initiative started earlier this year, but resources related to instance-status were still pending.

instance-status is responsible for ensuring the connection and heartbeat between instances in a multi-instance monolithic Rocket.Chat deployment.

Since the Moleculer framework is already in use, we moved the lifecycle management of connections to it, such as node initialization, listing, etc.

As a result, it is no longer necessary to ping MongoDB and wait for a Change Stream notification to interpret a given node as valid.

The same timeout and heartbeat interval rules have been added to Moleculer:

  • heartbeatInterval: process.env.MULTIPLE_INSTANCES_PING_INTERVAL || 10
  • heartbeatTimeout: process.env.MULTIPLE_INSTANCES_EXPIRE || Math.ceil((defaultPingInterval * 3) / 60) * 60

Issue(s)

Steps to test or reproduce

To validate these changes, you will need to run a multi-instance monolithic Rocket.Chat deployment.

Navigate to the apps/meteor directory and run the following command to start the first instance:

cd apps/meteor
TEST_MODE=true CI=true DISABLE_DB_WATCHERS=true meteor

Navigate to the build directory and execute the following:

cd ./apps/meteor/.meteor/local/build
cd .. && cd build && MONGO_URL=mongodb://localhost:3001/meteor INSTANCE_IP=localhost ROOT_URL=http://localhost:3000 PORT=3030 TEST_MODE=true DB_WATCHERS_DISABLED=true node main.js

This setup runs multi-instance communication using the TCP transporter. If you prefer to use NATS, you’ll need to include the NATS_TRANSPORTER environment variable. However, the changes primarily affect TCP connections.

Further comments

ricardogarim avatar Dec 06 '24 15:12 ricardogarim

Looks like this PR is ready to merge! 🎉 If you have any trouble, please check the PR guidelines

dionisio-bot[bot] avatar Dec 06 '24 15:12 dionisio-bot[bot]

PR Preview Action v1.4.8 :---: :rocket: Deployed preview to https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-34134/ on branch gh-pages at 2024-12-17 15:55 UTC

github-actions[bot] avatar Dec 06 '24 15:12 github-actions[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 75.83%. Comparing base (1a11303) to head (adb41b3). Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #34134   +/-   ##
========================================
  Coverage    75.83%   75.83%           
========================================
  Files          511      511           
  Lines        22171    22171           
  Branches      5397     5397           
========================================
  Hits         16813    16813           
  Misses        4710     4710           
  Partials       648      648           
Flag Coverage Δ
unit 75.83% <ø> (ø)

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

codecov[bot] avatar Dec 06 '24 15:12 codecov[bot]

⚠️ No Changeset found

Latest commit: adb41b3c01ce0bb1a13eca611aa44009563bf08e

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

changeset-bot[bot] avatar Dec 06 '24 16:12 changeset-bot[bot]