https://github.com/agent-hellboy/grpc-request-dedup
https://github.com/agent-hellboy/grpc-request-dedup
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/agent-hellboy/grpc-request-dedup
- Owner: Agent-Hellboy
- License: mit
- Created: 2024-10-15T22:28:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-16T17:35:04.000Z (over 1 year ago)
- Last Synced: 2025-02-04T08:29:40.582Z (over 1 year ago)
- Language: Go
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# grpc-request-dedup
This project provides a gRPC middleware for request deduplication, helping achieve idempotency in gRPC-based systems. It's designed as a Proof of Concept (PoC) to demonstrate how to handle duplicate requests.
## Features
- Intercepts gRPC unary calls to detect and handle duplicate requests
- Uses request IDs to uniquely identify each request
- Caches responses for duplicate requests, reducing unnecessary processing
- Can helps achieve idempotency in distributed systems if I ever make it useable
## How It Works
1. The middleware intercepts incoming gRPC requests.
2. It extracts a unique request ID from the request metadata.
3. If the request ID is found in the cache, the cached response is returned immediately.
4. For new requests, the handler is called, and the response is cached before being returned.
## Benefits
- **Idempotency**: Ensures that multiple identical requests produce the same result.
- **Efficiency**: Reduces server load by avoiding redundant processing of duplicate requests.
- **Consistency**: Help maintain data consistency
## Use Cases
- Retry scenarios: Safely handle client retries without side effects.
- Network issues: Gracefully handle requests that may be sent multiple times due to network problems.
## Limitations
- This is a Proof of Concept and may need further refinement for production use.
- The current implementation uses an in-memory cache, which may not be suitable for all distributed scenarios.
- Cache expiration and cleanup strategies are not implemented in this PoC.
## Getting Started
[Include instructions on how to integrate this middleware into a gRPC server]
## Contributing
This project is open for contributions. Feel free to submit issues, feature requests, or pull requests to help improve this PoC.
## License
This project is licensed under the MIT License. See the LICENSE file for details.