Overview
This gRPC endpoint follows Domain-Driven Design principles to retrieve a list of Book aggregate roots from the Catalog bounded context. The operation is implemented as a query that doesn’t modify state, adhering to CQRS patterns.
The query handler maps the domain entities to a list of BookDto responses 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.
Architecture
Usage
Call ListBooks using grpcurl
You can use grpcurl to call the GetBooks
(or ListBooks
) method of the BookGrpcService
defined in your book.proto
:
grpcurl -plaintext \
-d '{"bookIds": ["<BOOK_ID_1>", "<BOOK_ID_2>"]}' \
localhost:5001 \
CatalogApi.BookGrpcService/GetBooks
- Replace
<BOOK_ID_1>
,<BOOK_ID_2>
, etc. with actual book IDs (strings). To list all books, you may pass an empty array or omit the field if supported by your implementation. - Adjust the host/port (
localhost:5001
) as needed for your environment. - The response will be a
BooksResponse
message as defined in your proto:
{
"books": [
{
"id": "...",
"name": "...",
"price": { "units": 12, "nanos": 0 },
"priceSale": { "units": 10, "nanos": 0 },
"status": "InStock"
},
// ... more books ...
]
}
Schema does not contain any properties.