-
Notifications
You must be signed in to change notification settings - Fork 2
feat: implement request/response pattern over Kafka #6
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add HTTP request/response routing through Kafka topics - Implement correlation ID handling for request matching - Add configurable timeout support (default 30s) - Support custom HTTP status codes in responses - Preserve all HTTP headers in Kafka messages - Add comprehensive tests for request/response flows - Update schema to support requestResponse configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add detailed How It Works section explaining the flow - Include complete configuration examples with all options - Provide step-by-step usage examples with curl commands - Document response headers and error handling scenarios - Add use cases for microservice communication patterns - Update main feature list to highlight new capability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add new header constants for path params and query string data - Automatically extract path parameters from URL routes - Pass path parameters as JSON in x-plt-kafka-hooks-path-params header - Pass query string parameters as JSON in x-plt-kafka-hooks-query-string header - Support Fastify path parameter syntax (e.g., /users/:userId/orders/:orderId) - Add comprehensive tests for path params, query strings, and combined usage - Update documentation with examples and header reference tables - Maintain backward compatibility with existing functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add complete end-to-end integration tests demonstrating real-world usage - Test path parameters and query string extraction and forwarding - Test error handling with custom HTTP status codes - Demonstrate microservice communication patterns via Kafka - Show how kafka-hooks enables decoupled, reliable service architecture - Include realistic scenarios with user profiles, orders, and error cases - Verify correlation ID handling and message flow integrity - Test both successful responses and error conditions The integration tests demonstrate: - HTTP → Kafka → Processing Service → Kafka → HTTP flow - Path parameters: /api/users/:userId/orders/:orderId - Query strings: ?include=items&format=detailed¤cy=USD - JSON request/response payloads with complex nested data - Error responses with custom status codes (404, 500, etc.) - Complete microservice architecture patterns 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ShogunPanda
reviewed
May 26, 2025
README.md
Outdated
| "code": "HTTP_ERROR_REQUEST_TIMEOUT", | ||
| "error": "Request Timeout", | ||
| "message": "Request timeout", | ||
| "statusCode": 408 |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong. 4xx are client errors, but here we're returning a server error. I would use 500, 503 or 504.
Use 504 Gateway Timeout instead of 408 Request Timeout for request/response pattern timeouts, as this is more appropriate for scenarios where the gateway times out waiting for an upstream service. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Member
Author
|
@ShogunPanda PTAL |
ShogunPanda
approved these changes
May 27, 2025
Contributor
ShogunPanda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
x-status-codeheaderFeatures Added
Core Request/Response Flow
Configuration
New
requestResponsearray in kafka config:{ "requestResponse": [ { "path": "/api/process", "requestTopic": "request-topic", "responseTopic": "response-topic", "timeout": 5000 } ] }Enhanced Header Processing
Usage Example
HTTP Request:
Flow:
request-topicwith correlation IDresponse-topicTest Coverage
Backward Compatibility
Fully backward compatible - existing functionality unchanged.
🤖 Generated with Claude Code
Fixes #2