-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
loadbalancer: remove RoundRobinLoadBalancerBuilderProvider (#3137)
Motivation: Now that DefaultLoadBalancer is in the main loadbalancer package we can avoid using a provider to facilitate the migration. Modifications: Remove the migration provider and instead use the types directly.
- Loading branch information
1 parent
e4d4418
commit 441c2bc
Showing
6 changed files
with
133 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 0 additions & 149 deletions
149
...cer/src/main/java/io/servicetalk/loadbalancer/RoundRobinToDefaultLBMigrationProvider.java
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...urces/META-INF/services/io.servicetalk.loadbalancer.RoundRobinLoadBalancerBuilderProvider
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...balancer/src/test/java/io/servicetalk/loadbalancer/RoundRobinLoadBalancerFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright © 2024 Apple Inc. and the ServiceTalk project authors | ||
* | ||
* Licensed 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 io.servicetalk.loadbalancer; | ||
|
||
import io.servicetalk.client.api.ConnectionFactory; | ||
import io.servicetalk.client.api.LoadBalancer; | ||
import io.servicetalk.concurrent.api.Publisher; | ||
import io.servicetalk.concurrent.api.Single; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.parallel.Execution; | ||
import org.junit.jupiter.api.parallel.ExecutionMode; | ||
|
||
import static io.servicetalk.loadbalancer.RoundRobinLoadBalancerFactory.ROUND_ROBIN_USER_DEFAULT_LOAD_BALANCER; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
|
||
@Execution(ExecutionMode.SAME_THREAD) | ||
final class RoundRobinLoadBalancerFactoryTest { | ||
|
||
@AfterEach | ||
void cleanup() { | ||
System.clearProperty(ROUND_ROBIN_USER_DEFAULT_LOAD_BALANCER); | ||
} | ||
|
||
@Test | ||
void generateDefaultLoadBalancerIfEnabled() { | ||
System.setProperty(ROUND_ROBIN_USER_DEFAULT_LOAD_BALANCER, "true"); | ||
assertThat(getLoadBalancer(), instanceOf(DefaultLoadBalancer.class)); | ||
} | ||
|
||
@Test | ||
void doesNotGenerateDefaultLoadBalancerIfDisabled() { | ||
System.setProperty(ROUND_ROBIN_USER_DEFAULT_LOAD_BALANCER, "false"); | ||
assertThat(getLoadBalancer(), instanceOf(RoundRobinLoadBalancer.class)); | ||
} | ||
|
||
@Test | ||
void defaultResultIsDefaultLoadBalancer() { | ||
assertThat(getLoadBalancer(), instanceOf(DefaultLoadBalancer.class)); | ||
} | ||
|
||
static LoadBalancer<TestLoadBalancedConnection> getLoadBalancer() { | ||
ConnectionFactory<String, TestLoadBalancedConnection> connectionFactory = | ||
new TestConnectionFactory(ignored -> Single.never()); | ||
return RoundRobinLoadBalancers.<String, TestLoadBalancedConnection>builder("balancer").build() | ||
.newLoadBalancer(Publisher.never(), connectionFactory, "targetResource"); | ||
} | ||
} |
Oops, something went wrong.