Skip to content

feat(payments): add circuit breaker for payment provider#1071

Open
greatKhalifa-code wants to merge 1 commit into
rinafcode:mainfrom
greatKhalifa-code:feat/payment-provider-circuit-breaker
Open

feat(payments): add circuit breaker for payment provider#1071
greatKhalifa-code wants to merge 1 commit into
rinafcode:mainfrom
greatKhalifa-code:feat/payment-provider-circuit-breaker

Conversation

@greatKhalifa-code

Copy link
Copy Markdown

Wraps all IPaymentProvider HTTP calls with an opossum CircuitBreaker to prevent a slow/unavailable gateway from exhausting the connection pool.

  • Add PaymentProviderCircuitBreakerService (timeout 10s, 50% error threshold, 30s half-open probe interval, volumeThreshold 5)
  • Proxy all IPaymentProvider methods through the breaker; throw 503 ServiceUnavailableException when the circuit is OPEN
  • Register service in PaymentsModule (providers + exports)
  • Extend HealthIndicatorsService with checkPaymentProvider() and include paymentProvider in the readiness() map
  • Add PaymentProviderHealthController exposing GET /health/payment-provider (503/207/200 by circuit state) and GET /health/payment-provider/status
  • Update HealthModule to register new controller and providers
  • Add 21 unit tests covering CLOSED, OPEN, and HALF_OPEN states

Closes #825

Wraps all IPaymentProvider HTTP calls with an opossum CircuitBreaker to
prevent a slow/unavailable gateway from exhausting the connection pool.

- Add PaymentProviderCircuitBreakerService (timeout 10s, 50% error
  threshold, 30s half-open probe interval, volumeThreshold 5)
- Proxy all IPaymentProvider methods through the breaker; throw 503
  ServiceUnavailableException when the circuit is OPEN
- Register service in PaymentsModule (providers + exports)
- Extend HealthIndicatorsService with checkPaymentProvider() and include
  paymentProvider in the readiness() map
- Add PaymentProviderHealthController exposing GET /health/payment-provider
  (503/207/200 by circuit state) and GET /health/payment-provider/status
- Update HealthModule to register new controller and providers
- Add 21 unit tests covering CLOSED, OPEN, and HALF_OPEN states

Closes #payment-circuit-breaker
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@greatKhalifa-code Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far!
Kindly fix your workflow to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add circuit breaker around external payment provider calls

2 participants