vttranlina commented on code in PR #2420: URL: https://github.com/apache/james-project/pull/2420#discussion_r1778285795
########## backends-common/redis/src/main/java/org/apache/james/backends/redis/RedisHealthCheck.scala: ########## @@ -154,3 +156,36 @@ class RedisMasterReplicaHealthCheckPerform(val redisConfiguration: MasterReplica .subscribe() } + +class RedisSentinelHealthCheckPerform(val redisURI: RedisURI, + val maybeSentinelPassword: Option[String], + val healthcheckTimeout: Duration) extends RedisHealthcheckPerform { + + private val PING_SUCCESS_RESPONSE = "PONG" + + private val redisClient: RedisClient = { + maybeSentinelPassword.foreach(password => redisURI.getSentinels.forEach(uri => uri.setCredentialsProvider(RedisCredentialsProvider.from(() => RedisCredentials.just("", password))))) Review Comment: This line code (167) looks not relate to the method `RedisClient` We can done it (set password credential) for mutable RedisURI at the `SentinelRedisConfiguration.from` With that way, we don't need (maybeSentinelPassword: Option[String]) in `SentinelRedisConfiguration` object. more pretty code ########## server/mailet/rate-limiter-redis/src/test/java/org/apache/james/rate/limiter/TopologyRedisRateLimiterTest.scala: ########## @@ -0,0 +1,48 @@ +/** ************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + * ************************************************************** */ + +package org.apache.james.rate.limiter + +import java.time.Duration + +import eu.timepit.refined.auto._ +import org.apache.james.backends.redis.RedisConfiguration +import org.apache.james.rate.limiter.TopologyRedisRateLimiterTest.{RULES, SLIDING_WIDOW_PRECISION} +import org.apache.james.rate.limiter.api.{AcceptableRate, RateLimitingResult, Rule, Rules, TestKey} +import org.apache.james.rate.limiter.redis.RedisRateLimiterFactory +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import reactor.core.scala.publisher.SMono + +object TopologyRedisRateLimiterTest { + val SLIDING_WIDOW_PRECISION: Option[Duration] = Some(Duration.ofSeconds(1)) + val RULES = Rules(Seq(Rule(4L, Duration.ofSeconds(2)))) +} + +trait TopologyRedisRateLimiterTest { Review Comment: do we need extract old code to new contract class when only single impl `RedisRateLimiterWithMasterReplicaTopologyTest` ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org