Overview
This gRPC endpoint follows Domain-Driven Design principles to retrieve a specific Book aggregate root from the Catalog bounded context by its unique identifier. The operation is implemented as a query that doesn’t modify state, adhering to CQRS patterns.
The query handler maps the domain entity to a BookDto response through an auto-mapper profile, ensuring that domain implementation details remain encapsulated. The endpoint respects the aggregate boundaries and only exposes data appropriate for the presentation layer.
Key Features
- High Performance: gRPC binary protocol for efficient data transfer
- Strong Typing: Protocol buffer definitions ensure type safety
- Streaming Support: Capable of server streaming for bulk operations
- Cross-Platform: Works with any gRPC-compatible client
Architecture
Usage
Call GetBook using grpcurl
You can use grpcurl to call the GetBook
method of the BookGrpcService
defined in your book.proto
:
grpcurl -plaintext \ -d '{"bookId": "<BOOK_ID>"}' \ localhost:5001 \ CatalogApi.BookGrpcService/GetBook
- Replace
<BOOK_ID>
with the actual book ID (string). - Adjust the host/port (
localhost:5001
) as needed for your environment. - The response will be a
BookResponse
message as defined in your proto:
{ "id": "<BOOK_ID>", "name": "Atomic Habits", "price": { "units": 12, "nanos": 0 }, "priceSale": { "units": 10, "nanos": 0 }, "status": "InStock"}
The unique identifier for the book
The name of the book
The price of the book
The sale price of the book
The status of the book