Skip to content

Conversation

yavor300
Copy link
Contributor

Add support for reactive Resilience4jBulkheadProvider

  • Introduced ReactiveResilience4jBulkheadProvider to provide bulkhead support for reactive operations (Mono and Flux).
  • The provider decorates reactive streams (Mono and Flux) with a SemaphoreBulkhead to enforce concurrency limits.
  • Integrated ReactiveResilience4jBulkheadProvider into the run methods for Mono and Flux to handle bulkhead constraints, along with optional CircuitBreaker and TimeLimiter configurations.
  • Usage in the run methods:
    • For Mono<T>:
      1. The bulkheadProvider.decorateMono method decorates the Mono with bulkhead protection.
      2. The decorated Mono is then transformed with CircuitBreaker logic (CircuitBreakerOperator).
      3. If a TimeLimiter is configured, a timeout is applied, and any timeout error is reported to the CircuitBreaker.
      4. A fallback is applied to handle errors gracefully.
    • For Flux<T>:
      1. Similar decoration and transformations are applied for bulkhead, CircuitBreaker, and TimeLimiter.
      2. Fallback logic ensures graceful degradation for errors.
  • Ensured that only SemaphoreBulkhead is used for reactive scenarios since FixedThreadPoolBulkhead is not supported.
  • Updated configuration and tests to validate the behavior and integration of the provider in reactive streams.

This MR addresses issues #166 and #105 by introducing ReactiveResilience4jBulkheadProvider for handling bulkhead constraints in reactive streams.
Refs #166, #105

…head support for reactive operations (Mono and Flux).
…head support for reactive operations (Mono and Flux).
@yavor300
Copy link
Contributor Author

Closes #166, #105

…head support for reactive operations (Mono and Flux).
@ryanjbaxter
Copy link
Contributor

Thanks! This is great!

If you would like we could merge this into our next minor release but we would have to rework the PR a bit to remove any kind of breaking changes to the APIs (changes to public method signatures).

If not we can wait till the next major to merge it (which would be in a few months).

Either way it would be nice to add some documentation about the reactive support.

@ryanjbaxter ryanjbaxter added enhancement New feature or request and removed waiting-for-triage labels Jan 7, 2025
…head support for reactive operations (Mono and Flux).
@yavor300
Copy link
Contributor Author

yavor300 commented Jan 7, 2025

Thanks for the feedback!

I prefer to merge this into your next minor release.

I have reworked the PR by adding additional constructors instead of changing the existing public method signatures.

The only place a public method signature (bean declaration) is changed is inside the ReactiveResilience4JAutoConfiguration class but this is done because we need to inject the ReactiveResilience4jBulkheadProvider bean into the ReactiveResilience4JCircuitBreakerFactory.

Should I create a separate bean method that includes the ReactiveResilience4jBulkheadProvider and mark the current one as @Primary?

Also, I agree to document that change.

@ryanjbaxter
Copy link
Contributor

No for the configuration class you can change that public method. Just mark the old constructors as @Deprecated

…head support for reactive operations (Mono and Flux).
@yavor300
Copy link
Contributor Author

yavor300 commented Jan 7, 2025

I annotated the old constructors with @Deprecated and extended the bulkhead-pattern-supporting documentation with an explanation of the newly added provider.

@yavor300
Copy link
Contributor Author

Just for clarification, when are you planning your next minor release?

@spencergibb
Copy link
Member

Watch here for updates. We're doing some planning very soon and will add a date there.

@ryanjbaxter
Copy link
Contributor

After discussing scheduling with the team, the next minor will be in the June timeframe. You can keep an eye on our milestone dates for the most up to date information. That said we will likely merge this before the end of the month once we have a branch.

@ryanjbaxter ryanjbaxter added this to the 2.2.0-M1 milestone Jan 23, 2025
@ryanjbaxter ryanjbaxter merged commit abddcd8 into spring-cloud:main Jan 23, 2025
1 check passed
@ryanjbaxter ryanjbaxter linked an issue Jan 30, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Add Support For Reactive Bulkheads

4 participants