Skip to content

Commit 6865ebb

Browse files
author
pellse
committed
Initial rewrite
1 parent d558d1b commit 6865ebb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ The Assembler library can be used in situations where an application needs to ac
1616
5. Creating a single point of entry: The Assembler library can be used to create a single point of entry for different systems, making it easier for clients to access the functionality they need.
1717

1818
## Usage Example
19-
Below is an example of generating transaction information from a list of customers of an online store. Assuming the following fictional data model and api to access different services:
19+
Here is an example of how to use the Assembler Library to generate transaction information from a list of customers of an online store. This example assumes the following fictional data model and API to access different services:
2020
```java
2121
public record Customer(Long customerId, String name) {}
2222
public record BillingInfo(Long id, Long customerId, String creditCardNumber) {}
2323
public record OrderItem(String id, Long customerId, String orderDescription, Double price) {}
2424
public record Transaction(Customer customer, BillingInfo billingInfo, List<OrderItem> orderItems) {}
2525

26-
Flux<Customer> getCustomers(); // Call to a REST or RSocket microservice
27-
Flux<BillingInfo> getBillingInfo(List<Long> customerIds); // Connects to relational database (R2DBC)
28-
Flux<OrderItem> getAllOrders(List<Long> customerIds); // Connects to MongoDB (Reactive Streams Driver)
26+
Flux<Customer> getCustomers(); // e.g. call to a microservice, or a Flux connected to a Kafka source
27+
Flux<BillingInfo> getBillingInfo(List<Long> customerIds); // e.g. connects to relational database (R2DBC)
28+
Flux<OrderItem> getAllOrders(List<Long> customerIds); // e.g. connects to MongoDB (Reactive Streams Driver)
2929
```
3030
In cases where the `getCustomers()` method returns a substantial number of customers, retrieving the associated `BillingInfo` for each customer would require an additional call per `customerId`. This would result in a considerable increase in network calls, causing the N + 1 queries issue. To mitigate this, we can retrieve all the `BillingInfo` for all the customers returned by `getCustomers()` with a single additional call. The same approach can be used for retrieving OrderItem information.
3131

0 commit comments

Comments
 (0)