Skip to content

Commit bc38fb3

Browse files
committed
docs: embed the rendered class diagram in the scatter-gather README
Render etc/scatter-gather.urm.puml to PNG and embed it in the detailed explanation section, matching the other modules, instead of the inline mermaid block.
1 parent ff263fb commit bc38fb3

2 files changed

Lines changed: 2 additions & 80 deletions

File tree

‎scatter-gather/README.md‎

Lines changed: 2 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ sequenceDiagram
6565
ScatterGather->>Client: aggregate() returns Harbor Stays 295.50
6666
```
6767

68+
![Scatter-Gather class diagram](./etc/scatter-gather.urm.png)
69+
6870
## Programmatic Example of Scatter-Gather Pattern in Java
6971

7072
The request is a plain immutable value. Every recipient receives exactly the same instance.
@@ -194,86 +196,6 @@ Aggregate phase: choosing the cheapest of 2 quotes
194196
Best offer: Harbor Stays at 295.50
195197
```
196198

197-
## Class Diagram
198-
199-
```mermaid
200-
classDiagram
201-
class RateRequest {
202-
+String city
203-
+LocalDate checkIn
204-
+int nights
205-
}
206-
207-
class RateQuote {
208-
+String provider
209-
+BigDecimal total
210-
}
211-
212-
class RateProvider {
213-
<<interface>>
214-
+name() String
215-
+quote(RateRequest request) RateQuote
216-
}
217-
218-
class InMemoryRateProvider {
219-
-String name
220-
-BigDecimal nightlyRate
221-
+name() String
222-
+quote(RateRequest request) RateQuote
223-
}
224-
225-
class DelayedRateProvider {
226-
-RateProvider delegate
227-
-Duration delay
228-
+name() String
229-
+quote(RateRequest request) RateQuote
230-
}
231-
232-
class FailingRateProvider {
233-
-String name
234-
+name() String
235-
+quote(RateRequest request) RateQuote
236-
}
237-
238-
class Aggregator~T, R~ {
239-
<<interface>>
240-
+aggregate(List~T~ replies) R
241-
+cheapestQuote()$ Aggregator
242-
}
243-
244-
class PendingReply {
245-
+RateProvider provider
246-
+CompletableFuture~RateQuote~ reply
247-
}
248-
249-
class ScatterGather {
250-
-ExecutorService executor
251-
-Duration timeout
252-
+scatter(RateRequest request, List~RateProvider~ providers) List~PendingReply~
253-
+gather(List~PendingReply~ pending) List~RateQuote~
254-
+scatterGather(RateRequest request, List~RateProvider~ providers, Aggregator aggregator) R
255-
+close() void
256-
}
257-
258-
class App {
259-
+main(String[] args)$ void
260-
~reportBestOffer(Optional~RateQuote~ best)$ void
261-
}
262-
263-
InMemoryRateProvider ..|> RateProvider
264-
DelayedRateProvider ..|> RateProvider
265-
FailingRateProvider ..|> RateProvider
266-
DelayedRateProvider --> RateProvider : delegates to
267-
RateProvider ..> RateRequest : reads
268-
RateProvider ..> RateQuote : answers with
269-
ScatterGather *-- PendingReply : nested record
270-
ScatterGather ..> RateProvider : calls
271-
ScatterGather ..> Aggregator : reduces with
272-
PendingReply --> RateProvider
273-
PendingReply ..> RateQuote
274-
App ..> ScatterGather
275-
```
276-
277199
## When to Use the Scatter-Gather Pattern in Java
278200

279201
* The same question has to be answered by several independent services, such as price comparison, search federation, or quorum reads.
68.8 KB
Loading

0 commit comments

Comments
 (0)