Skip to content

Conversation

@uglide
Copy link
Collaborator

@uglide uglide commented Dec 9, 2025

The code example showcases how to use the current API.

@uglide uglide requested review from atakavci and ggivo December 9, 2025 15:13
@uglide uglide changed the base branch from main to feature/automatic-failover-1 December 9, 2025 15:13
@uglide uglide force-pushed the im/aa-demo-example branch 2 times, most recently from e258449 to 97342ef Compare December 9, 2025 15:54
…he builder

 - When using the builder without setting healthCheckStrategySupplier: Health checks will use PingStrategy.DEFAULT
 - When explicitly setting to null: Health checks will be disabled (as documented)
 - When setting to a custom supplier: Uses the custom health check strategy

 Example Usage:
 // Uses PingStrategy.DEFAULT for health checks
 DatabaseConfig config1 = DatabaseConfig.builder(uri)
     .weight(1.0f)
     .build();

 // Explicitly disables health checks
 DatabaseConfig config2 = DatabaseConfig.builder(uri)
     .healthCheckStrategySupplier(null)
     .build();

 // Uses custom health check strategy
 DatabaseConfig config3 = DatabaseConfig.builder(uri)
     .healthCheckStrategySupplier(customSupplier)
     .build();
// To create DatabaseConfig use provided builder
DatabaseConfig config = DatabaseConfig.builder(redisURI)
    .weight(1.5f)
    .clientOptions(options)
    .circuitBreakerConfig(cbConfig)
    .healthCheckStrategySupplier(supplier)
    .build();
// Minimal configuration with defaults
CircuitBreakerConfig config = CircuitBreakerConfig.builder().build();

// Custom configuration
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .failureRateThreshold(25.0f)
    .minimumNumberOfFailures(500)
    .metricsWindowSize(5)
    .build();

// With custom tracked exceptions
Set<Class<? extends Throwable>> customExceptions = new HashSet<>();
customExceptions.add(RuntimeException.class);

CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .failureRateThreshold(15.5f)
    .minimumNumberOfFailures(200)
    .trackedExceptions(customExceptions)
    .metricsWindowSize(3)
    .build();
//Combine add and remove
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .addTrackedExceptions(MyCustomException.class)
    .removeTrackedExceptions(TimeoutException.class)
    .build();

// Replace all tracked exceptions
Set<Class<? extends Throwable>> customExceptions = new HashSet<>();
customExceptions.add(RuntimeException.class);
customExceptions.add(IOException.class);
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .trackedExceptions(customExceptions)
    .build();
@uglide uglide force-pushed the im/aa-demo-example branch from 97342ef to a5693a4 Compare December 10, 2025 16:02
@ggivo ggivo requested a review from atakavci December 11, 2025 10:38
Copy link
Collaborator

@atakavci atakavci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Co-authored-by: atakavci <a_takavci@yahoo.com>
@ggivo ggivo merged commit 8d1796f into feature/automatic-failover-1 Dec 11, 2025
9 checks passed
@ggivo ggivo deleted the im/aa-demo-example branch December 11, 2025 11:53
Copy link
Contributor

@ggivo ggivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

4 participants