You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-10Lines changed: 44 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ The Circuit Breaker design pattern is used to increase application stability, im
11
11
*[Installation](#installation)
12
12
*[Usage](#usage)
13
13
*[API](#api)
14
+
*[License](#license)
14
15
15
16
## Swift version
16
17
The latest version of CircuitBreaker works with the `4.0.3` and newer version of the Swift binaries. You can download this version of the Swift binaries by following this [link](https://swift.org/download/#releases).
@@ -28,7 +29,7 @@ To leverage the CircuitBreaker package in your Swift application, you should spe
@@ -189,6 +190,20 @@ CircuitBreaker(timeout: Int = 1000, resetTimeout: Int = 60000, maxFailures: Int
189
190
*`command` Contextual function to circuit break, which allows user defined failures (the context provides an indirect reference to the corresponding circuit breaker instance).
The CircuitBreaker library provides an interface for observing new CircuitBreaker instances in order to register and track stat changes. In the initialization of a CircuitBreaker instance, the linked monitors are notified of its instantiation allowing them to begin tracking the instance's stats. The CircuitBreaker instance exposes a Hystrix compliant stat snapshot to the monitor which can then be processed accordingly.
225
+
226
+
```swift
227
+
228
+
/// Initialize stat monitors
229
+
let monitor1 =SwiftMetrics()
230
+
let monitor2 =...
231
+
...
232
+
let monitorN =...
233
+
234
+
/// Register monitors
235
+
CircuitBreaker.addMonitor(monitor1)
236
+
CircuitBreaker.addMonitor(monitor2)
237
+
...
238
+
CircuitBreaker.addMonitor(monitorN)
239
+
240
+
// Create instances of CircuitBreaker
241
+
let circuit1 =CircuitBreaker()
242
+
let circuit2 =CircuitBreaker()
243
+
...
244
+
let circuitN =CircuitBreaker()
245
+
```
246
+
247
+
As mentioned above, the initializer takes care of notifying each one of the monitors of the new CircuitBreaker instance.
214
248
215
249
## License
216
250
This Swift package is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE).
0 commit comments