-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Stork configuration under the quarkus namespace
- Loading branch information
1 parent
a44856b
commit 8e1b5a5
Showing
19 changed files
with
213 additions
and
49 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
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
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
6 changes: 3 additions & 3 deletions
6
...-reactive/rest-client-reactive/deployment/src/test/resources/stork-application.properties
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
stork.hello-service.service-discovery=static | ||
stork.hello-service.service-discovery.address-list=${quarkus.http.host}:${quarkus.http.test-port} | ||
stork.hello-service.load-balancer=least-response-time | ||
quarkus.stork.service-configuration.hello-service.service-discovery.type=static | ||
quarkus.stork.service-configuration.hello-service.service-discovery.params.address-list=${quarkus.http.host}:${quarkus.http.test-port} | ||
quarkus.stork.service-configuration.hello-service.load-balancer.type=least-response-time | ||
|
||
hello2/mp-rest/url=stork://hello-service/hello |
6 changes: 3 additions & 3 deletions
6
...ctive/rest-client-reactive/deployment/src/test/resources/stork-dev-application.properties
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
stork.hello-service.service-discovery=static | ||
stork.hello-service.service-discovery.address-list=${quarkus.http.host}:${quarkus.http.port} | ||
stork.hello-service.load-balancer=least-response-time | ||
quarkus.stork.service-configuration.hello-service.service-discovery.type=static | ||
quarkus.stork.service-configuration.hello-service.service-discovery.params.address-list=${quarkus.http.host}:${quarkus.http.port} | ||
quarkus.stork.service-configuration.hello-service.load-balancer.type=least-response-time | ||
|
||
hello2/mp-rest/url=stork://hello-service/hello |
6 changes: 3 additions & 3 deletions
6
...easy-reactive/rest-client-reactive/deployment/src/test/resources/stork-stat-lb.properties
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
stork.hello-service.service-discovery=static | ||
stork.hello-service.service-discovery.address-list=${quarkus.http.host}:${quarkus.http.test-port},localhost:8766 | ||
stork.hello-service.load-balancer=least-response-time | ||
quarkus.stork.service-configuration.hello-service.service-discovery.type=static | ||
quarkus.stork.service-configuration.hello-service.service-discovery.params.address-list=${quarkus.http.host}:${quarkus.http.test-port},localhost:8766 | ||
quarkus.stork.service-configuration.hello-service.load-balancer.type=least-response-time | ||
hello2/mp-rest/url=stork://hello-service/hello |
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
19 changes: 19 additions & 0 deletions
19
extensions/smallrye-stork/runtime/src/main/java/io/quarkus/stork/ServiceConfiguration.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,19 @@ | ||
package io.quarkus.stork; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
|
||
@ConfigGroup | ||
public class ServiceConfiguration { | ||
/** | ||
* ServiceDiscovery configuration for the service | ||
*/ | ||
@ConfigItem | ||
public StorkServiceDiscoveryConfiguration serviceDiscovery; | ||
|
||
/** | ||
* LoadBalancer configuration for the service | ||
*/ | ||
@ConfigItem | ||
public StorkLoadBalancerConfiguration loadBalancer; | ||
} |
7 changes: 6 additions & 1 deletion
7
extensions/smallrye-stork/runtime/src/main/java/io/quarkus/stork/SmallRyeStorkRecorder.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
27 changes: 27 additions & 0 deletions
27
extensions/smallrye-stork/runtime/src/main/java/io/quarkus/stork/StorkConfigProvider.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,27 @@ | ||
package io.quarkus.stork; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import io.smallrye.stork.api.config.ServiceConfig; | ||
import io.smallrye.stork.spi.config.ConfigProvider; | ||
|
||
public class StorkConfigProvider implements ConfigProvider { | ||
|
||
private static final List<ServiceConfig> serviceConfigs = new ArrayList<>(); | ||
|
||
public static void init(List<ServiceConfig> configs) { | ||
serviceConfigs.addAll(configs); | ||
} | ||
|
||
@Override | ||
public List<ServiceConfig> getConfigs() { | ||
return serviceConfigs; | ||
} | ||
|
||
@Override | ||
public int priority() { | ||
return 150; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
extensions/smallrye-stork/runtime/src/main/java/io/quarkus/stork/StorkConfigUtil.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,30 @@ | ||
package io.quarkus.stork; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import io.smallrye.stork.api.config.ServiceConfig; | ||
import io.smallrye.stork.spi.config.SimpleServiceConfig; | ||
|
||
public class StorkConfigUtil { | ||
|
||
public static List<ServiceConfig> toStorkServiceConfig(StorkConfiguration storkConfiguration) { | ||
List<ServiceConfig> storkServicesConfigs = new ArrayList<>(); | ||
Set<String> servicesConfigs = storkConfiguration.serviceConfiguration.keySet(); | ||
SimpleServiceConfig.Builder builder = new SimpleServiceConfig.Builder(); | ||
for (String serviceName : servicesConfigs) { | ||
builder.setServiceName(serviceName); | ||
ServiceConfiguration serviceConfiguration = storkConfiguration.serviceConfiguration.get(serviceName); | ||
SimpleServiceConfig.SimpleServiceDiscoveryConfig storkServiceDiscoveryConfig = new SimpleServiceConfig.SimpleServiceDiscoveryConfig( | ||
serviceConfiguration.serviceDiscovery.type, serviceConfiguration.serviceDiscovery.params); | ||
builder.setServiceDiscovery(storkServiceDiscoveryConfig); | ||
SimpleServiceConfig.SimpleLoadBalancerConfig loadBalancerConfig = new SimpleServiceConfig.SimpleLoadBalancerConfig( | ||
serviceConfiguration.loadBalancer.type, serviceConfiguration.loadBalancer.parameters); | ||
builder.setLoadBalancer(loadBalancerConfig); | ||
storkServicesConfigs.add(builder.build()); | ||
} | ||
return storkServicesConfigs; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
extensions/smallrye-stork/runtime/src/main/java/io/quarkus/stork/StorkConfiguration.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,25 @@ | ||
package io.quarkus.stork; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.runtime.annotations.ConfigDocMapKey; | ||
import io.quarkus.runtime.annotations.ConfigDocSection; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
/** | ||
* Stork configuration root. | ||
*/ | ||
@ConfigRoot(phase = ConfigPhase.RUN_TIME) | ||
public class StorkConfiguration { | ||
|
||
/** | ||
* ServiceDiscovery configuration for the service | ||
*/ | ||
@ConfigItem | ||
@ConfigDocSection | ||
@ConfigDocMapKey("service-name") | ||
public Map<String, ServiceConfiguration> serviceConfiguration; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...smallrye-stork/runtime/src/main/java/io/quarkus/stork/StorkLoadBalancerConfiguration.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,27 @@ | ||
package io.quarkus.stork; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
|
||
@ConfigGroup | ||
public class StorkLoadBalancerConfiguration { | ||
|
||
/** | ||
* Configures load balancer type, e.g. "round-robin". | ||
* A LoadBalancerProvider for the type has to be available | ||
* | ||
*/ | ||
@ConfigItem(defaultValue = "round-robin") | ||
public String type; | ||
|
||
/** | ||
* Load Balancer parameters. | ||
* Check the documentation of the selected load balancer type for available parameters | ||
* | ||
*/ | ||
@ConfigItem | ||
public Map<String, String> parameters; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...lrye-stork/runtime/src/main/java/io/quarkus/stork/StorkServiceDiscoveryConfiguration.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,27 @@ | ||
package io.quarkus.stork; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
|
||
@ConfigGroup | ||
public class StorkServiceDiscoveryConfiguration { | ||
|
||
/** | ||
* Configures the service discovery type, e.g. "consul". | ||
* ServiceDiscoveryProvider for the type has to be available | ||
* | ||
*/ | ||
@ConfigItem | ||
public String type; | ||
|
||
/** | ||
* ServiceDiscovery parameters. | ||
* Check the documentation of the selected service discovery type for available parameters. | ||
* | ||
*/ | ||
@ConfigItem | ||
public Map<String, String> params; | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
.../runtime/src/main/resources/META-INF/services/io.smallrye.stork.spi.config.ConfigProvider
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 @@ | ||
io.quarkus.stork.StorkConfigProvider |
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
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
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
6 changes: 3 additions & 3 deletions
6
integration-tests/rest-client-reactive-stork/src/main/resources/application.properties
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
stork.hello-service.service-discovery=my | ||
stork.hello-service.load-balancer=least-response-time | ||
quarkus.stork.service-configuration.hello-service.service-discovery.type=my | ||
quarkus.stork.service-configuration.hello-service.load-balancer.type=least-response-time | ||
hello/mp-rest/url=stork://hello-service/hello | ||
# slow-service and fast-service come from Slow- and FastWiremockServer | ||
stork.hello-service.service-discovery.address-list=${slow-service},${fast-service} | ||
quarkus.stork.service-configuration.hello-service.service-discovery.params.address-list=${slow-service},${fast-service} |