Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions README.MD

This file was deleted.

35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
On first Hit:

<img width="746" alt="image" src="https://github.com/rahulvaish/SpringBoot-Java/assets/689226/fe749372-b6b8-45b9-8b42-6c82309c801f">
<img width="488" alt="image" src="https://github.com/rahulvaish/SpringBoot-Java/assets/689226/06da2867-7279-4a96-a31e-88a4b51067ac">

____________________________________________________________________


When Service B is down:
<br>
Because sliding-window-size: 10 and failure-rate-threshold: 50 that means out of 10 if 5 failed the circuit will jump to Open state
<img width="745" alt="image" src="https://github.com/rahulvaish/SpringBoot-Java/assets/689226/ca81ccae-1200-4d41-894d-338437e38f02">
<img width="532" alt="image" src="https://github.com/rahulvaish/SpringBoot-Java/assets/689226/2fd290af-c52c-4210-978c-0621458dd849">

____________________________________________________________________


In Open state, after 5 seconds it turns into Half Open state, now try 3 times (because wait-duration-in-open-state: 5000ms and permitted-number-of-calls-in-half-open-state: 3)
<br>
If 2/3 pass -> Circuit Open, else, Circuit Closed.
<br>
In my case, I kept Service B shut, so circuit got open:
<br>
<img width="519" alt="image" src="https://github.com/rahulvaish/SpringBoot-Java/assets/689226/72409ff0-eda0-4099-88fd-165b57720e2b">


____________________________________________________________________

Now, I turned the ServiceB up and running, and after 5 seconds (In Half Open state) I tried 3 times (because wait-duration-in-open-state: 5000ms and permitted-number-of-calls-in-half-open-state: 3)
<br>
All 3/3 pass -> Circuit Closed.
<img width="749" alt="image" src="https://github.com/rahulvaish/SpringBoot-Java/assets/689226/19049681-505e-4984-8dc9-5250efee70df">
<img width="509" alt="image" src="https://github.com/rahulvaish/SpringBoot-Java/assets/689226/2a205c3f-fd31-45ad-9766-00ed37c18fab">

Note: While n/3 hits were in attempt the circuit was in half open state.
Binary file added ServiceA/.DS_Store
Binary file not shown.
37 changes: 37 additions & 0 deletions ServiceA/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
36 changes: 36 additions & 0 deletions ServiceA/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
plugins {
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}

group = 'com.example.serviceA'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
mavenCentral()
}

ext {
set('springCloudVersion', "2021.0.4")
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: '2.7.5'

implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.7.5'
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file added ServiceA/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions ServiceA/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
240 changes: 240 additions & 0 deletions ServiceA/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading