CircuitBreakerTime
The demo for the Swift Cloud Workshop 3 talk on Circuit Breakers with Swift
Table of Contents
Background
This is final demo for the Swift Cloud Workshop 3 talk on Circuit Breakers with Swift. This demo contains a webserver that demonstrates how to use two different versions of a circuit breaker. They are a light weight implementation called SGCircuitBreaker and IBM-Swift's Circuit Breaker.
Requirements
- Swift 4.0 and greater
- macOS: 10.9 and greater
- Linux
- Make build utility
- Docker
Install
Repo setup
In a terminal, you can clone the repo like so:
$ git clone git@github.com:eman6576/CircuitBreakerTime.git
then change into the directory like so:
$ cd CircuitBreakerTime
Build project
To build the project and open it in Xcode, you can enter this command:
$ make all
To reset the build directories and rebuild, you can use:
$ make clean_all
Usage
Running The Server
The webserver can run on both macOS and Linux.
To run the webserver in macOS, use:
$ make run_local
To run the webserver in Linux using Docker, use:
$ make run_linux
Endpoints
The base url of the webserver is http://localhost:8090
. There are five endpoints that you can access:
These endpoints use an instance of SGCircuitBreaker
.
/swiftyguerrero
- GET
/success
: Simulates a successful operation and notifies the client that it was intially successful. - GET
/success-delay
: Simulates a operation that timesout the first time and then succeds the second time. - GET
/failure
: Simulates a operation that failed and that would trip the circuit.
- GET
These endpoints use an instance of IBM-Swift's CircuitBreaker
.
/ibm
- GET
/success
: Simulates a successful operation and notifies the client that it was intially successful. - GET
/failure
: Simulates a operation that failed and that would trip the circuit.
- GET