Node Microservice
Most analytical, interpretive, or persuasive essays tend to follow the same basic pattern. This structure should help you formulate effective outlines for most essays.
Micro Services
- Posts
- Comments
- Query Service
- Event Bus
TO DO
Comment Moderation
- Comment Service
- On create comment emit event CreateComment with comment info to Event bus
- Event Bus
- Publish event to all subscriber
- Moderate Comment Service
- Receive CreateComment event
- Update comment
- Emit CommentModerated with updated status to comment to Event bus
- Event Bus
- Publish event to all subscriber
- Comment Service
- Receive CommentModerated event
- Update comment with status
- Emit CommentUpdated to Event bus
- Event Bus
- Publish event to all subscriber
- Query Service
- Receive CommentUpdated event
- Update comment
Key Notes
- Handling one-to-many relation in microservice
For example fetch posts with their all comment
- Approach #1 Sync Communication
Send all list of post ids to comment service and map comment response to related post and send back to client.
- Pros
- Easy to understand
- Cons
- Introduces a dependency between services
- if any inter-service request fails, the overall requests fails
- The entire request is only as fast as the slowest request
- Can easily introduce webs of requests
- Pros
- Approach #2 - Async Communication through Event Bus
Introduce Event Bus and Query Service
-
Event Bus
- Listen for post and comment creation
- Emit event for both
-
Query Service
- Listen for post and comment creation
- Keep in required data structure and update
-
Pros
- Query service has zero dependency on other service
- Fast to retrieve data
-
Cons
- Data duplication
- Hard to understand
-
- Approach #1 Sync Communication
Send all list of post ids to comment service and map comment response to related post and send back to client.