Skip to content

Commit

Permalink
Merge pull request #24400 from michalszynkiewicz/simplify-stork-confi…
Browse files Browse the repository at this point in the history
…guration
  • Loading branch information
gastaldi authored Mar 18, 2022
2 parents ed08535 + bb86e46 commit 70432fd
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/stork-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ For each service expected to be exposed as a Kubernetes Service, configure the l
[source, properties]
----
quarkus.stork.my-service.service-discovery.type=kubernetes
quarkus.stork.my-service.service-discovery.params.k8s-namespace=my-namespace
quarkus.stork.my-service.service-discovery.k8s-namespace=my-namespace
----

Stork looks for the Kubernetes Service with the given name (`my-service` in the previous example) in the specified namespace.
Expand Down Expand Up @@ -148,7 +148,7 @@ public class AcmeServiceDiscoveryProvider // <3>
This implementation is straightforward.

<1> `@ServiceDiscoveryType` annotation defines the type of the service discovery provider. For each `ServiceDiscoveryProvider` annotated with this annotation, a configuration class will be generated. The name of the configuration class is constructed by appending `Configuration` to the name of the provider.
<2> Use `@ServiceDiscoveryAttribute` to define configuration properties for services configured with this service discovery provider. Configuration properties are gathered from all properties of a form: `quarkus.stork.my-service.service-discovery.params.attr=value`.
<2> Use `@ServiceDiscoveryAttribute` to define configuration properties for services configured with this service discovery provider. Configuration properties are gathered from all properties of a form: `quarkus.stork.my-service.service-discovery.attr=value`.
<3> The provider needs to implement `ServiceDiscoveryType` typed by the configuration class.
<4> `createServiceDiscovery` method is the factory method. It receives the configuration and access to the name of the service and available infrastructure.

Expand Down Expand Up @@ -202,8 +202,8 @@ Then, in the configuration, just add:
[source, properties]
----
quarkus.stork.my-service.service-discovery.type=acme
quarkus.stork.my-service.service-discovery.params.host=localhost
quarkus.stork.my-service.service-discovery.params.port=1234
quarkus.stork.my-service.service-discovery.host=localhost
quarkus.stork.my-service.service-discovery.port=1234
----

Then, Stork will use your implementation to locate the `my-service` service.
Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/asciidoc/stork.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ consul.host=localhost
consul.port=8500
quarkus.stork.my-service.service-discovery.type=consul
quarkus.stork.my-service.service-discovery.params.consul-host=localhost
quarkus.stork.my-service.service-discovery.params.consul-port=8500
quarkus.stork.my-service.service-discovery.consul-host=localhost
quarkus.stork.my-service.service-discovery.consul-port=8500
quarkus.stork.my-service.load-balancer.type=round-robin
----

Expand All @@ -318,7 +318,7 @@ The first two lines provide the Consul location used by the `Registration` bean.
The other properties are related to Stork.
`stork.my-service.service-discovery` indicates which type of service discovery we will be using to locate the `my-service` service.
In our case, it's `consul`.
`quarkus.stork.my-service.service-discovery.params.consul-host` and `quarkus.stork.my-service.service-discovery.params.consul-port` configures the access to Consul.
`quarkus.stork.my-service.service-discovery.consul-host` and `quarkus.stork.my-service.service-discovery.consul-port` configures the access to Consul.
Finally, `quarkus.stork.my-service.load-balancer.type` configures the service selection.
In our case, we use a `round-robin`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void shouldModifyStorkSettings() {
// @formatter:on

TEST.modifyResourceFile("application.properties",
v -> v.replaceAll("quarkus.stork.hello-service.service-discovery.params.address-list=.*",
"quarkus.stork.hello-service.service-discovery.params.address-list=localhost:8766"));
v -> v.replaceAll("quarkus.stork.hello-service.service-discovery.address-list=.*",
"quarkus.stork.hello-service.service-discovery.address-list=localhost:8766"));
// @formatter:off
when()
.get("/helper")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
quarkus.stork.hello-service.service-discovery.type=static
quarkus.stork.hello-service.service-discovery.params.address-list=${quarkus.http.host}:${quarkus.http.test-port}
quarkus.stork.hello-service.service-discovery.address-list=${quarkus.http.host}:${quarkus.http.test-port}
quarkus.stork.hello-service.load-balancer.type=least-response-time

hello2/mp-rest/url=stork://hello-service/hello
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
quarkus.stork.hello-service.service-discovery.type=static
quarkus.stork.hello-service.service-discovery.params.address-list=${quarkus.http.host}:${quarkus.http.port}
quarkus.stork.hello-service.service-discovery.address-list=${quarkus.http.host}:${quarkus.http.port}
quarkus.stork.hello-service.load-balancer.type=least-response-time

hello2/mp-rest/url=stork://hello-service/hello
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
quarkus.stork.hello-service.service-discovery.type=static
quarkus.stork.hello-service.service-discovery.params.address-list=${quarkus.http.host}:${quarkus.http.test-port},localhost:8766
quarkus.stork.hello-service.service-discovery.address-list=${quarkus.http.host}:${quarkus.http.test-port},localhost:8766
quarkus.stork.hello-service.load-balancer.type=least-response-time
hello2/mp-rest/url=stork://hello-service/hello
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class StorkLoadBalancerConfiguration {
* Check the documentation of the selected load balancer type for available parameters
*
*/
@ConfigItem
@ConfigItem(name = ConfigItem.PARENT)
public Map<String, String> parameters;

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class StorkServiceDiscoveryConfiguration {
* Check the documentation of the selected service discovery type for available parameters.
*
*/
@ConfigItem
@ConfigItem(name = ConfigItem.PARENT)
public Map<String, String> params;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ quarkus.grpc.clients.hello.override-authority=localhost
quarkus.grpc.clients.hello.name-resolver=stork

quarkus.stork."hello-service".service-discovery.type=static
quarkus.stork."hello-service".service-discovery.params.address-list=${quarkus.http.host}:9000
%test.quarkus.stork."hello-service".service-discovery.params.address-list=${quarkus.http.host}:9001
quarkus.stork."hello-service".service-discovery.address-list=${quarkus.http.host}:9000
%test.quarkus.stork."hello-service".service-discovery.address-list=${quarkus.http.host}:9001
quarkus.stork."hello-service".load-balancer.type=round-robin

quarkus.grpc.clients.hello.ssl.certificate=src/main/resources/tls/client.pem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ quarkus.grpc.clients.hello.host=hello-service
quarkus.grpc.clients.hello.name-resolver=stork

quarkus.stork.hello-service.service-discovery.type=static
%test.quarkus.stork.hello-service.service-discovery.params.address-list=badd-url:9001,${quarkus.http.host}:9001
quarkus.stork.hello-service.service-discovery.params.address-list=badd-url:9000,${quarkus.http.host}:9000
%test.quarkus.stork.hello-service.service-discovery.address-list=badd-url:9001,${quarkus.http.host}:9001
quarkus.stork.hello-service.service-discovery.address-list=badd-url:9000,${quarkus.http.host}:9000
quarkus.stork.hello-service.load-balancer.type=round-robin
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ quarkus.grpc.clients.hello1.name-resolver=stork
quarkus.grpc.clients.hello2.name-resolver=stork

quarkus.stork.hello-service1.service-discovery.type=static
quarkus.stork.hello-service1.service-discovery.params.address-list=localhost:9013,localhost:9012
quarkus.stork.hello-service1.service-discovery.address-list=localhost:9013,localhost:9012
quarkus.stork.hello-service1.load-balancer.type=least-response-time

quarkus.stork.hello-service2.service-discovery.type=static
quarkus.stork.hello-service2.service-discovery.params.address-list=localhost:9013,localhost:9012
quarkus.stork.hello-service2.service-discovery.address-list=localhost:9013,localhost:9012
quarkus.stork.hello-service2.load-balancer.type=least-response-time

#quarkus.log.category."io.quarkus.grpc.runtime.stork".level=DEBUG
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ quarkus.stork.hello-service.service-discovery.type=my
quarkus.stork.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
quarkus.stork.hello-service.service-discovery.params.address-list=${slow-service},${fast-service}
quarkus.stork.hello-service.service-discovery.address-list=${slow-service},${fast-service}

0 comments on commit 70432fd

Please sign in to comment.