-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- default service discovery - default load balncer
- Loading branch information
pablo gonzalez granados
committed
Mar 21, 2022
1 parent
40b0804
commit cd59788
Showing
17 changed files
with
131 additions
and
89 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
45 changes: 0 additions & 45 deletions
45
service-discovery/stork-consul/src/main/java/io/quarkus/ts/stork/PongResource.java
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
service-discovery/stork-consul/src/test/resources/test.properties
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
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
File renamed without changes.
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
54 changes: 54 additions & 0 deletions
54
service-discovery/stork/src/main/java/io/quarkus/ts/stork/PongResource.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,54 @@ | ||
package io.quarkus.ts.stork; | ||
|
||
import java.util.UUID; | ||
|
||
import javax.enterprise.event.Observes; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
import io.quarkus.vertx.web.Route; | ||
import io.quarkus.vertx.web.RouteBase; | ||
import io.vertx.ext.consul.ConsulClientOptions; | ||
import io.vertx.ext.consul.ServiceOptions; | ||
import io.vertx.ext.web.RoutingContext; | ||
import io.vertx.mutiny.core.Vertx; | ||
import io.vertx.mutiny.ext.consul.ConsulClient; | ||
|
||
@RouteBase(path = "/pong", produces = MediaType.TEXT_PLAIN) | ||
public class PongResource { | ||
|
||
public static final String PONG_SERVICE_NAME = "pong"; | ||
private static final String DEFAULT_PONG_RESPONSE = "pong"; | ||
private static final String HEADER_ID = "x-id"; | ||
private String instanceUniqueId; | ||
|
||
@ConfigProperty(name = "stork.pong.service-discovery.consul-host", defaultValue = "localhost") | ||
String host; | ||
@ConfigProperty(name = "stork.pong.service-discovery.consul-port", defaultValue = "8500") | ||
String port; | ||
@ConfigProperty(name = "pong-service-port", defaultValue = "8080") | ||
String pongPort; | ||
@ConfigProperty(name = "pong-service-host", defaultValue = "localhost") | ||
String pongHost; | ||
@ConfigProperty(name = "stork.pong.service-discovery", defaultValue = "consul") | ||
String serviceDiscoveryType; | ||
|
||
public void init(@Observes StartupEvent ev, Vertx vertx) { | ||
instanceUniqueId = UUID.randomUUID().toString(); | ||
if (serviceDiscoveryType.equalsIgnoreCase("consul")) { | ||
ConsulClient client = ConsulClient.create(vertx, | ||
new ConsulClientOptions().setHost(host).setPort(Integer.parseInt(port))); | ||
|
||
client.registerServiceAndAwait( | ||
new ServiceOptions().setPort(Integer.parseInt(pongPort)).setAddress(pongHost).setName(PONG_SERVICE_NAME) | ||
.setId("pong")); | ||
} | ||
} | ||
|
||
@Route(path = "/", methods = Route.HttpMethod.GET) | ||
public void pong(final RoutingContext context) { | ||
context.response().putHeader(HEADER_ID, instanceUniqueId).end(DEFAULT_PONG_RESPONSE); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ts.pung.openshift.use-internal-service-as-url=true | ||
ts.pong.openshift.use-internal-service-as-url=true |