Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds circuit breaker support to the FTP library to prevent cascade failures when the FTP server is experiencing issues. The circuit breaker implementation follows the classic three-state pattern (CLOSED, OPEN, HALF_OPEN) and uses a sliding window of time buckets to track failure rates.
Changes:
- Added circuit breaker implementation with configurable failure thresholds and sliding window tracking
- Integrated circuit breaker checks into FTP client operations to fail fast when the server is unavailable
- Added new
CircuitBreakerOpenErrorerror type as a subtype ofServiceUnavailableError - Added comprehensive configuration options for circuit breaker behavior including failure categories
- Updated documentation and added test coverage
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| native/src/main/java/io/ballerina/stdlib/ftp/util/FtpUtil.java | Added CircuitBreakerOpenError to ErrorType enum |
| native/src/main/java/io/ballerina/stdlib/ftp/util/FtpConstants.java | Added circuit breaker constants for configuration |
| native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/*.java | Core circuit breaker implementation including state machine, health tracking, failure categorization, and configuration |
| native/src/main/java/io/ballerina/stdlib/ftp/client/FtpClient.java | Integrated circuit breaker checks before operations and outcome recording after operations |
| ballerina/error.bal | Added CircuitBreakerOpenError type definition |
| ballerina/commons.bal | Added FailureCategory enum, RollingWindow and CircuitBreakerConfig types |
| ballerina/client_endpoint.bal | Added circuitBreaker configuration field to ClientConfiguration |
| docs/spec/spec.md | Added circuit breaker documentation including configuration, state machine, and usage examples |
| changelog.md | Added circuit breaker feature to changelog |
| ballerina/tests/circuit_breaker_test.bal | Added tests for circuit breaker configuration validation and basic functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreaker.java
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitHealth.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreakerConfig.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreakerConfig.java
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@niveathika I've opened a new pull request, #1535, to work on those changes. Once the pull request is ready, I'll request review from you. |
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (78.64%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1534 +/- ##
============================================
- Coverage 80.38% 78.64% -1.75%
- Complexity 831 914 +83
============================================
Files 63 70 +7
Lines 3712 4125 +413
Branches 621 717 +96
============================================
+ Hits 2984 3244 +260
- Misses 461 587 +126
- Partials 267 294 +27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 14 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitHealth.java
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitHealth.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreakerConfig.java
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreakerConfig.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreaker.java
Outdated
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread. Only fix the unresolved comments |
|
@niveathika I've opened a new pull request, #1536, to work on those changes. Once the pull request is ready, I'll request review from you. |
f54a4be to
a98e1a1
Compare
4b822fe to
205305d
Compare
205305d to
d9d7d58
Compare
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/Bucket.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreaker.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreaker.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreakerConfig.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreakerConfig.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitBreakerConfig.java
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/client/circuitbreaker/CircuitHealth.java
Outdated
Show resolved
Hide resolved
…tter concurrency Co-authored-by: niveathika <27669465+niveathika@users.noreply.github.com>
…it-breaker-pattern Replace synchronized blocks with StampedLock in CircuitBreaker
|
|
ffc21a0 to
9d506b3
Compare
|



Purpose
Fixes ballerina-platform/ballerina-library#8382
Examples
Checklist