fix resiliency readme files

Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
This commit is contained in:
Mukundan Sundararajan 2022-12-02 13:15:23 +05:30
parent 96b009a832
commit d54902b7af
2 changed files with 45 additions and 45 deletions

View File

@ -6,13 +6,13 @@ Visit [this](https://docs.dapr.io/operations/resiliency/resiliency-overview//) l
This quickstart includes one service:
- Client service `order-processor`
- Client service `order-processor`
- Redis component spec `statestore.yaml`
- Resiliency spec `resiliency.yaml`
### Run the client service with Dapr and resiliency enabled
1. Navigate to the app directory, install dependencies, and run the service with resiliency enabled via the config.yaml:
1. Navigate to the app directory, install dependencies, and run the service with resiliency enabled via the config.yaml:
### CSharp example:
```bash
@ -40,17 +40,17 @@ dapr run --app-id order-processor --config ../config.yaml --components-path ../.
```bash
cd ../state_management/javascript/sdk/order-processor
npm install
dapr run --app-id order-processor ../config.yaml --components-path ../../../components/ -- npm start
dapr run --app-id order-processor --config ../config.yaml --components-path ../../../components/ -- npm start
```
### Python example:
```bash
cd ../state_management/python/sdk/order-processor
pip3 install -r requirements.txt
dapr run --app-id order-processor ../config.yaml --components-path ../../../components/ -- python3
pip3 install -r requirements.txt
dapr run --app-id order-processor --config ../config.yaml --components-path ../../../components/ -- python3 app.py
```
### Expected output:
### Expected output:
```bash
== APP == Saving Order: { orderId: '1' }
== APP == Getting Order: { orderId: '1' }
@ -63,7 +63,7 @@ dapr run --app-id order-processor ../config.yaml --components-path ../../../comp
```
<!-- END_STEP -->
### Simulate a component failure by stopping the Redis container instance
### Simulate a component failure by stopping the Redis container instance
In a new terminal window, stop the Redis container that's running on your machine:
```bash
@ -77,18 +77,18 @@ Policies defined in the resiliency.yaml spec:
retryForever:
policy: constant
maxInterval: 5s
maxRetries: -1
maxRetries: -1
circuitBreakers:
simpleCB:
maxRequests: 1
timeout: 5s
timeout: 5s
trip: consecutiveFailures >= 5
```
Applied policies:
```bash
INFO[0006] Error processing operation component[statestore] output. Retrying...
INFO[0006] Error processing operation component[statestore] output. Retrying...
INFO[0026] Circuit breaker "simpleCB-statestore" changed state from closed to open
INFO[0031] Circuit breaker "simpleCB-statestore" changed state from open to half-open
INFO[0031] Circuit breaker "simpleCB-statestore" changed state from half-open to open

View File

@ -6,16 +6,16 @@ Visit [this](https://docs.dapr.io/operations/resiliency/resiliency-overview//) l
This quickstart includes one service:
- Caller service `checkout`
- Callee service `order-processor`
- Caller service `checkout`
- Callee service `order-processor`
- Resiliency spec `resiliency.yaml`
### Run both services with Dapr and resiliency enabled
1. Open two terminal windows. In one terminal window, navigate to the `checkout` service. In the other terminal window, navigate to the `order-processor` service. Install dependencies for each service and run both services with resiliency enabled via the config.yaml:
1. Open two terminal windows. In one terminal window, navigate to the `checkout` service. In the other terminal window, navigate to the `order-processor` service. Install dependencies for each service and run both services with resiliency enabled via the config.yaml:
### CSharp example:
##### Order Processor Service:
##### Order Processor Service:
```bash
cd ../service_invocation/csharp/http/order-processor
dotnet restore
@ -23,7 +23,7 @@ dotnet build
dapr run --app-port 7001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- dotnet run
```
##### Checkout Service:
##### Checkout Service:
```bash
cd ../service_invocation/csharp/http/checkout
dotnet restore
@ -32,14 +32,14 @@ dapr run --app-id checkout --config ../config.yaml --components-path ../../../c
```
### Go example:
##### Order Processor Service:
##### Order Processor Service:
```bash
cd ../service_invocation/go/http/order-processor
go build .
dapr run --app-port 6001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- go run .
```
##### Checkout Service:
##### Checkout Service:
```bash
cd ../service_invocation/go/http/checkout
go build .
@ -47,14 +47,14 @@ dapr run --app-id checkout --config ../config.yaml --components-path ../../../c
```
### Java example:
##### Order Processor Service:
##### Order Processor Service:
```bash
cd ../service_invocation/java/http/order-processor
mvn clean install
dapr run --app-id order-processor --config ../config.yaml --components-path --app-port 9001 --app-protocol http --dapr-http-port 3501 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar
```
##### Checkout Service:
##### Checkout Service:
```bash
cd ../service_invocation/java/http/checkout
mvn clean install
@ -62,14 +62,14 @@ dapr run --app-id checkout --config ../config.yaml --components-path ../../../co
```
### JavaScript example:
##### Order Processor Service:
##### Order Processor Service:
```bash
cd ../service_invocation/javascript/http/order-processor
npm install
dapr run --app-port 5001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- npm start
```
##### Checkout Service:
##### Checkout Service:
```bash
cd ../service_invocation/javascript/http/checkout
npm install
@ -77,21 +77,21 @@ dapr run --app-id checkout --config ../config.yaml --components-path ../../../c
```
### Python example:
##### Order Processor Service:
##### Order Processor Service:
```bash
cd ../service_invocation/python/http/order-processor
pip3 install -r requirements.txt
dapr run --app-port 8001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- python3 app.py
pip3 install -r requirements.txt
dapr run --app-port 8001 --app-id order-processor --config ../config.yaml --components-path ../../../components/ --app-protocol http --dapr-http-port 3501 -- python3 app.py
```
##### Checkout Service:
##### Checkout Service:
```bash
cd ../service_invocation/python/http/checkout
pip3 install -r requirements.txt
pip3 install -r requirements.txt
dapr run --app-id checkout --config ../config.yaml --components-path ../../../components/ --app-protocol http --dapr-http-port 3500 -- python3 app.py
```
### Expected output:
### Expected output:
Once both services are running, the `order-processor` service will recieve orders from the `checkout`service continuously using Dapr's service invoke API.
##### `order-processor` output:
@ -101,11 +101,11 @@ Once both services are running, the `order-processor` service will recieve order
== APP == Order received: { orderId: 3 }
```
### Simulate ann application failure by stopping the `order-processor` service
### Simulate an application failure by stopping the `order-processor` service
Simulate a system failure by stopping the `order-processor` service running in your second terminal window.
##### Windows
##### Windows
```script
CTRL + C
```
@ -122,54 +122,54 @@ Policies defined in the resiliency.yaml spec:
retryForever:
policy: constant
maxInterval: 5s
maxRetries: -1
maxRetries: -1
circuitBreakers:
simpleCB:
maxRequests: 1
timeout: 5s
timeout: 5s
trip: consecutiveFailures >= 5
```
##### Applied policies:
```bash
INFO[0005] Error processing operation endpoint[order-processor, order-processor:orders]. Retrying...
INFO[0025] Circuit breaker "order-processor:orders" changed state from closed to open
INFO[0030] Circuit breaker "order-processor:orders" changed state from open to half-open
INFO[0030] Circuit breaker "order-processor:orders" changed state from half-open to open
INFO[0005] Error processing operation endpoint[order-processor, order-processor:orders]. Retrying...
INFO[0025] Circuit breaker "order-processor:orders" changed state from closed to open
INFO[0030] Circuit breaker "order-processor:orders" changed state from open to half-open
INFO[0030] Circuit breaker "order-processor:orders" changed state from half-open to open
```
### Simulate the application recovering by restarting the order-processor service:
Simulate the `order-processor` service recovering by restarting the application using the `dapr run` command:
### CSharp example:
##### Order Processor Service:
##### Order Processor Service:
```bash
dapr run --app-port 7001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- dotnet run
dapr run --app-port 7001 --app-id order-processor --config ../config.yaml --components-path ../../../components/ --app-protocol http --dapr-http-port 3501 -- dotnet run
```
### Go example:
##### Order Processor Service:
##### Order Processor Service:
```bash
dapr run --app-port 6001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- go run .
dapr run --app-port 6001 --app-id order-processor --config ../config.yaml --components-path ../../../components/ --app-protocol http --dapr-http-port 3501 -- go run .
```
### Java example:
##### Order Processor Service:
##### Order Processor Service:
```bash
dapr run --app-id order-processor --config ../config.yaml --components-path --app-port 9001 --app-protocol http --dapr-http-port 3501 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar
dapr run --app-id order-processor --config ../config.yaml --components-path ../../../components/ --app-port 9001 --app-protocol http --dapr-http-port 3501 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar
```
### JavaScript example:
##### Order Processor Service:
##### Order Processor Service:
```bash
dapr run --app-port 5001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- npm start
dapr run --app-port 5001 --app-id order-processor --config ../config.yaml --components-path ../../../components/ --app-protocol http --dapr-http-port 3501 -- npm start
```
### Python example:
##### Order Processor Service:
##### Order Processor Service:
```bash
dapr run --app-port 8001 --app-id order-processor --config ../config.yaml --components-path --app-protocol http --dapr-http-port 3501 -- python3 app.py
dapr run --app-port 8001 --app-id order-processor --config ../config.yaml --components-path ../../../components/ --app-protocol http --dapr-http-port 3501 -- python3 app.py
```
### Observe orders have resumed sequentially: