Skip to content

Conversation

@nitish-egov
Copy link
Collaborator

@nitish-egov nitish-egov commented Jul 21, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced Kafka message production to support specifying a message key for each message.
  • Chores

    • Updated internal message handling to include a task identifier when producing Kafka messages during resource creation and mapping processes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 21, 2025

"""

Walkthrough

The changes introduce an optional key parameter to the produceModifiedMessages function in the Kafka producer module, allowing Kafka messages to include a specific key. Correspondingly, the utility functions that call this producer now pass a task-specific identifier as the key when producing messages for both resource creation and mapping processes. No other logic or control flow is altered.

Changes

File(s) Change Summary
health-services/project-factory/src/server/kafka/Producer.ts Updated produceModifiedMessages to accept an optional key parameter and include it in Kafka payload.
health-services/project-factory/src/server/utils/campaignUtils.ts Modified calls to produceModifiedMessages in createAllResources and createAllMappings to pass task name as the key.

Sequence Diagram(s)

sequenceDiagram
    participant CampaignUtils
    participant Producer
    participant Kafka

    CampaignUtils->>Producer: produceModifiedMessages(message, topic, tenantId, key)
    Producer->>Kafka: Send message with key (if provided)
    Kafka-->>Producer: Ack/response
    Producer-->>CampaignUtils: Promise resolves/rejects
Loading

Estimated code review effort

2 (~15 minutes)

Poem

A rabbit hopped through fields of code,
Adding keys to messages sent down the road.
Now each task can be tracked with care,
As Kafka receives them, aware.
With every hop, a key in tow—
The burrow’s messages neatly flow!
🐇✨
"""


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9706768 and e9ffd87.

📒 Files selected for processing (1)
  • health-services/project-factory/src/server/kafka/Producer.ts (2 hunks)
🧠 Learnings (1)
📓 Common learnings
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/LOCALSETUP.md:0-0
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The note in the LOCALSETUP.md file regarding error handling with Kafka and other microservices has been updated to provide more detailed troubleshooting steps.
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/LOCALSETUP.md:0-0
Timestamp: 2024-06-24T08:15:04.390Z
Learning: The note in the LOCALSETUP.md file regarding error handling with Kafka and other microservices has been updated to provide more detailed troubleshooting steps.
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/src/main/java/org/egov/processor/util/BoundaryUtil.java:33-44
Timestamp: 2024-10-08T20:11:07.772Z
Learning: devdatta-egov prefers using generic exception handlers in methods to potentially handle a broader range of exceptions.
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/src/main/java/org/egov/processor/util/BoundaryUtil.java:33-44
Timestamp: 2024-06-26T19:56:55.913Z
Learning: devdatta-egov prefers using generic exception handlers in methods to potentially handle a broader range of exceptions.
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/LOCALSETUP.md:0-0
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The note in the LOCALSETUP.md file regarding error handling with Kafka and other microservices has been updated to provide more detailed troubleshooting steps.
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/LOCALSETUP.md:0-0
Timestamp: 2024-06-24T08:15:04.390Z
Learning: The note in the LOCALSETUP.md file regarding error handling with Kafka and other microservices has been updated to provide more detailed troubleshooting steps.
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/src/main/java/org/egov/processor/util/BoundaryUtil.java:33-44
Timestamp: 2024-10-08T20:11:07.772Z
Learning: devdatta-egov prefers using generic exception handlers in methods to potentially handle a broader range of exceptions.
Learnt from: devdatta-egov
PR: egovernments/health-campaign-services#784
File: health-services/resource-estimation-service/src/main/java/org/egov/processor/util/BoundaryUtil.java:33-44
Timestamp: 2024-06-26T19:56:55.913Z
Learning: devdatta-egov prefers using generic exception handlers in methods to potentially handle a broader range of exceptions.
🔇 Additional comments (3)
health-services/project-factory/src/server/kafka/Producer.ts (3)

94-95: LGTM! Good addition for Kafka partitioning control.

The optional key parameter maintains backward compatibility while enabling message partitioning for improved parallelism. Messages with the same key will be routed to the same partition, ensuring ordered processing within that partition.


108-108: Correct implementation for Kafka key handling.

The key: key || null assignment properly handles both cases - when a key is provided for partitioning and when it's not (defaulting to null for round-robin distribution).


104-110: Well-implemented payload construction with key support.

The payload construction properly incorporates the optional key parameter. This change will enable:

  • Better parallelism through Kafka partitioning
  • Message ordering guarantees within the same partition
  • More predictable message distribution patterns

The implementation maintains the existing message structure while adding the key functionality.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

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.

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.

2 participants