@@ -297,33 +297,27 @@ and can also optionally check replication lag.
297297` LagAwareStrategy ` determines the health of the server using the
298298[ REST API] ({{< relref "/operate/rs/references/rest-api" >}}). The example
299299below shows how to configure ` LagAwareStrategy ` and activate it using
300- the ` healthCheckStrategySupplier ()` method of the ` MultiDbConfig.DatabaseConfig `
300+ the ` healthCheckStrategy ()` method of the ` MultiDbConfig.DatabaseConfig `
301301builder.
302302
303303``` java
304- BiFunction<HostAndPort , Supplier<RedisCredentials > , MultiDbConfig . StrategySupplier > healthCheckStrategySupplier =
305- (HostAndPort dbHostPort, Supplier<RedisCredentials > credentialsSupplier) - > {
306- LagAwareStrategy . Config lagConfig = LagAwareStrategy . Config . builder(dbHostPort, credentialsSupplier)
307- .interval(5000 ) // Check every 5 seconds
308- .timeout(3000 ) // 3 second timeout
309- .extendedCheckEnabled(true )
310- .build();
311-
312- return (hostAndPort, jedisClientConfig) - > new LagAwareStrategy (lagConfig);
313- };
304+ // Configure REST API endpoint and credentials
305+ HostAndPort restEndpoint = new HostAndPort (" redis-enterprise-db-fqdn" , 9443 );
306+ Supplier<RedisCredentials > credentialsSupplier = () - > new DefaultRedisCredentials (" rest-api-user" , " pwd" );
314307
315- // Configure REST API endpoint and credentials
316- HostAndPort restEndpoint = new HostAndPort (" redis-enterprise-db-fqdn" , 9443 );
317- Supplier<RedisCredentials > credentialsSupplier = () - > new DefaultRedisCredentials (" rest-api-user" , " pwd" );
318- // Build a single LagAwareStrategy based on REST endpoint and credentials
319- LagAwareStrategy . Config lagConfig = LagAwareStrategy . Config
308+ // Build a single LagAwareStrategy based on REST endpoint and credentials
309+ LagAwareStrategy . Config lagConfig = LagAwareStrategy . Config
320310 .builder(restEndpoint, credentialsSupplier)
321311 .interval(5000 ) // Check every 5 seconds
322312 .timeout(3000 ) // 3 second timeout
323313 .extendedCheckEnabled(true )
324314 .build();
325- MultiDbConfig . StrategySupplier lagAwareStrategySupplier = (hostAndPort,
326- jedisClientConfig) - > new LagAwareStrategy (lagConfig);
315+
316+ // Configure a database to use lag-aware health check
317+ MultiDbConfig . DatabaseConfig dbConfig =
318+ MultiDbConfig . DatabaseConfig . builder(hostAndPort, clientConfig)
319+ .healthCheckStrategy(new LagAwareStrategy (lagConfig))
320+ .build();
327321```
328322
329323### Custom health check strategy
0 commit comments