Skip to content

feat(new-webui): MongoCDC Framework#809

Closed
AVMatthews wants to merge 8 commits into
y-scope:mainfrom
AVMatthews:mongoCDC-framework
Closed

feat(new-webui): MongoCDC Framework#809
AVMatthews wants to merge 8 commits into
y-scope:mainfrom
AVMatthews:mongoCDC-framework

Conversation

@AVMatthews

Copy link
Copy Markdown
Contributor

Description

New framework built on MongoCDC using socket.io meant to replace our current usage of meteor's publish-subscribe framework.

TODO:

  • Linting
  • Unit Tests
  • Before merge return App.tsx back to original App.tsx (just changed for testing)

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Manually added collection to mongo replica and tested to see that the contest of the collection could be requested through the client from the server.

@coderabbitai

coderabbitai Bot commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread components/log-viewer-webui/client/package.json Outdated

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work

i understand this PR is still WIP. Let's use the suggestions as a checklist before requesting for a formal review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: changes in this file is to be removed.

Comment thread components/log-viewer-webui/client/package.json Outdated
Comment on lines +50 to +64
toArray () {
return new Promise((resolve, reject) => {
this.socket.emit("collection::find::toArray", {
query: this.findQuery,
options: this.findOptions,
}, (response: { error?: any; data?: any }) => {
if (response.error) {
return reject(response.error);
}

return resolve(response.data);
});
});
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: not in use at the moment.

/**
* @type {Listener}
*/
private listener: Listener | null = null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For private properties / functions, can we use the #propertyName syntax?

@@ -14,6 +14,11 @@ export default defineConfig({
target: "http://localhost:3000/",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the comment in L12-13 applies to both routes:

  1. Let move the comment to Line 11
  2. Let say "target host and port" instead of "target" to improve clarity.

@coderabbitai Let's create an issue to track the effort of serving Fastify routes under "/api". And we should replace this "/query/" proxy entry with "/api/" to ensure the other RESTful APIs are proxied to the backend.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@junhaoliao I'll create an issue to track this effort. Let me take care of that for you.


🏁 Script executed:

#!/bin/bash

# Create a GitHub issue to track the API routing changes
gh issue create \
  --title "Replace '/query/' proxy with '/api/' for RESTful endpoints" \
  --body "## Background
Currently, the log-viewer-webui client proxies API requests through the '/query/' path, but this doesn't account for other RESTful endpoints.

## Objective
- Serve all Fastify routes under the '/api/' path
- Update the Vite configuration to proxy '/api/' to the backend server instead of just '/query/'

## References
- Requested in PR: https://github.com/y-scope/clp/pull/809
- Discussion comment: https://github.com/y-scope/clp/pull/809#discussion_r2034462565

## Assignee
@junhaoliao" \
  --assignee junhaoliao \
  --repo y-scope/clp

Length of output: 718


@junhaoliao I've created an issue to track the effort of serving Fastify routes under "/api/" and replacing the "/query/" proxy entry. You can find it here: #810

The issue includes the objectives we discussed about updating the Vite configuration to ensure all RESTful APIs are properly proxied to the backend.

Comment thread components/log-viewer-webui/server/src/plugins/MongoReplicaServerPlugin.ts Outdated
Comment on lines +10 to +33
/**
* Initialize the MongoDB replica set.
*
* @param {FastifyInstance} fastify
* @return {Promise<void>}
* @throws {Error} If the replica set initialization fails.
*/
const initializeReplicaSet = async (fastify: FastifyInstance): Promise<void> => {
try {
const directMongoClient = new MongoClient(
"mongodb://localhost:27017",
{replicaSet: "rs0", directConnection: true}
);
const response = await directMongoClient.db("admin").admin()
.command({replSetInitiate: {}});

fastify.log.info("Replica set initialized:", response);
} catch (e) {
if (e instanceof MongoServerError && "AlreadyInitialized" === e.codeName) {
return;
}
throw new Error("Failed to initialize replica set", {cause: e});
}
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove all references to this, since the clp-package should have done the init in some Python script when starting the package.

Suggested change
/**
* Initialize the MongoDB replica set.
*
* @param {FastifyInstance} fastify
* @return {Promise<void>}
* @throws {Error} If the replica set initialization fails.
*/
const initializeReplicaSet = async (fastify: FastifyInstance): Promise<void> => {
try {
const directMongoClient = new MongoClient(
"mongodb://localhost:27017",
{replicaSet: "rs0", directConnection: true}
);
const response = await directMongoClient.db("admin").admin()
.command({replSetInitiate: {}});
fastify.log.info("Replica set initialized:", response);
} catch (e) {
if (e instanceof MongoServerError && "AlreadyInitialized" === e.codeName) {
return;
}
throw new Error("Failed to initialize replica set", {cause: e});
}
};
/**
* Initialize the MongoDB replica set.
*
* @param {FastifyInstance} fastify
* @return {Promise<void>}
* @throws {Error} If the replica set initialization fails.
*/
const initializeReplicaSet = async (fastify: FastifyInstance): Promise<void> => {
try {
const directMongoClient = new MongoClient(
"mongodb://localhost:27017",
{replicaSet: "rs0", directConnection: true}
);
const response = await directMongoClient.db("admin").admin()
.command({replSetInitiate: {}});
fastify.log.info("Replica set initialized:", response);
} catch (e) {
if (e instanceof MongoServerError && "AlreadyInitialized" === e.codeName) {
return;
}
throw new Error("Failed to initialize replica set", {cause: e});
}
};

Comment thread components/log-viewer-webui/server/src/plugins/MongoReplicaServerPlugin.ts Outdated
Comment thread components/log-viewer-webui/server/src/plugins/MongoReplicaServerPlugin.ts Outdated
Comment thread components/log-viewer-webui/server/src/plugins/MongoReplicaServerPlugin.ts Outdated
@junhaoliao

Copy link
Copy Markdown
Member

@AVMatthews / @davemarco / @hoophalab Please voice any preferences if you feel the mongoCdcLib / MongoReplicaCollection, etc. can be renamed. I got some ideas but would like to hear your thoughts first.

@davemarco

Copy link
Copy Markdown
Contributor

I looked briefly - does it make sense to keep this open as a WIP. Then have two smaller PRs for server and client. At almost ~1000, it may sense to split

Also for syntax, we normally only Uppercase first letter in code. so MongoCdc

@junhaoliao

junhaoliao commented Apr 9, 2025

Copy link
Copy Markdown
Member

I looked briefly - does it make sense to keep this open as a WIP. Then have two smaller PRs for server and client. At almost ~1000, it may sense to split

Also for syntax, we normally only Uppercase first letter in code. so MongoCdc

Getting the stuff cleaned in this PR first then submitting separately is a good idea.

By the way, I tend to avoid naming anything with "CDC" at this point because we're not currently handling (and for performance reasons even in the future we will not be always handling) the delta changes in the change packets.

@davemarco

Copy link
Copy Markdown
Contributor

replaced by #880 and #892

@davemarco davemarco closed this May 9, 2025
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.

3 participants