Skip to content

Commit afd73f2

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

2 files changed

Lines changed: 2 additions & 51 deletions

File tree

‎timeout/README.md‎

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ sequenceDiagram
5959
end
6060
```
6161

62+
![Timeout class diagram](./etc/timeout.urm.png)
63+
6264
## Programmatic Example of Timeout Pattern in Java
6365

6466
The example models an online shop that calls two downstream services. The product catalog is fast; the recommendation engine is slow. Each gets its own time limit.
@@ -205,57 +207,6 @@ Timeouts per service: {recommendations=1}
205207

206208
The "exceeded its 100 ms limit" line is written by the caller and the "interrupted, abandoning" line by the worker thread, so the two may appear in either order from run to run.
207209

208-
## Class Diagram
209-
210-
```mermaid
211-
classDiagram
212-
class TimeoutPolicy {
213-
<<record>>
214-
+String serviceName
215-
+Duration timeout
216-
+of(serviceName, millis)$ TimeoutPolicy
217-
}
218-
class TimeoutMetrics {
219-
-ConcurrentMap~String, AtomicInteger~ timeouts
220-
+recordTimeout(serviceName) void
221-
+timeoutCount(serviceName) int
222-
+snapshot() SortedMap~String, Integer~
223-
}
224-
class TimeoutExecutor {
225-
-ExecutorService executor
226-
-TimeoutMetrics metrics
227-
+execute(policy, call, fallback) T
228-
+metrics() TimeoutMetrics
229-
+close() void
230-
}
231-
class ServiceCallException {
232-
+ServiceCallException(serviceName, cause)
233-
}
234-
class DownstreamService {
235-
-String name
236-
-Duration latency
237-
-List~String~ items
238-
+name() String
239-
+fetch() List~String~
240-
}
241-
class App {
242-
-List~String~ POPULAR_ITEMS$
243-
+main(args)$ void
244-
~call(executor, policy, service, fallback)$ List~String~
245-
}
246-
247-
ServiceCallException --|> RuntimeException
248-
TimeoutExecutor --> TimeoutMetrics : counts timeouts in
249-
TimeoutExecutor ..> TimeoutPolicy : reads the limit from
250-
TimeoutExecutor ..> ServiceCallException : throws
251-
App ..> TimeoutPolicy : configures
252-
App ..> TimeoutExecutor : calls through
253-
App ..> TimeoutMetrics : reports
254-
App ..> DownstreamService : calls
255-
```
256-
257-
The same diagram is kept as PlantUML in [timeout.urm.puml](./etc/timeout.urm.puml).
258-
259210
## When to Use the Timeout Pattern in Java
260211

261212
* Whenever a call leaves the process: HTTP and gRPC calls, database queries, message broker round trips, third-party APIs.

‎timeout/etc/timeout.urm.png‎

44.8 KB
Loading

0 commit comments

Comments
 (0)