(NEW) Module "retry"
(NEW) Illustrative classes:
- App: simulates a production application
- BusinessOperation<T>: abstraction over any operation that can
potentially fail
- FindCustomer <: BusinessOperation<String>: illustrative
operation that can throw an error
- Retry <: BusinessOperation<T>: transparently implements the
retry mechanism
- Several "business" exceptions:
- BusinessException: top-level
- CustomerNotFoundException: can be ignored
- DatabaseNotAvailableException: fatal error
(NEW) .puml and .png for UML
This commit is contained in:
38
retry/etc/retry.urm.puml
Normal file
38
retry/etc/retry.urm.puml
Normal file
@@ -0,0 +1,38 @@
|
||||
@startuml
|
||||
package com.iluwatar.retry {
|
||||
class App {
|
||||
- LOG : Logger {static}
|
||||
- op : BusinessOperation<String> {static}
|
||||
+ App()
|
||||
- errorNoRetry() {static}
|
||||
- errorWithRetry() {static}
|
||||
+ main(args : String[]) {static}
|
||||
- noErrors() {static}
|
||||
}
|
||||
interface BusinessOperation<T> {
|
||||
+ perform() : T {abstract}
|
||||
}
|
||||
class FindCustomer {
|
||||
- customerId : String
|
||||
- errors : Deque<BusinessException>
|
||||
+ FindCustomer(customerId : String, errors : BusinessException[])
|
||||
+ perform() : String
|
||||
}
|
||||
class Retry<T> {
|
||||
- attempts : AtomicInteger
|
||||
- delay : long
|
||||
- errors : List<Exception>
|
||||
- maxAttempts : int
|
||||
- op : BusinessOperation<T>
|
||||
- test : Predicate<Exception>
|
||||
+ Retry<T>(op : BusinessOperation<T>, maxAttempts : int, delay : long, ignoreTests : Predicate<Exception>[])
|
||||
+ attempts() : int
|
||||
+ errors() : List<Exception>
|
||||
+ perform() : T
|
||||
}
|
||||
}
|
||||
Retry --> "-op" BusinessOperation
|
||||
App --> "-op" BusinessOperation
|
||||
FindCustomer ..|> BusinessOperation
|
||||
Retry ..|> BusinessOperation
|
||||
@enduml
|
||||
Reference in New Issue
Block a user