-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from quarkiverse/managed_channel
use a quarkus managed grpc channel
- Loading branch information
Showing
12 changed files
with
320 additions
and
38 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
36 changes: 36 additions & 0 deletions
36
...test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelConfigPriorityTest.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,36 @@ | ||
package io.quarkiverse.temporal.deployment; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.temporal.serviceclient.WorkflowServiceStubs; | ||
|
||
public class QuarkusManagedChannelConfigPriorityTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource( | ||
new StringAsset( | ||
"quarkus.temporal.start-workers: false\n" + | ||
"quarkus.temporal.channel-type: quarkus-managed\n" + | ||
"quarkus.grpc.clients.temporal-client.host: grpcHost\n" + | ||
"quarkus.temporal.connection.target: customTarget:1234\n"), | ||
"application.properties")); | ||
|
||
@Inject | ||
WorkflowServiceStubs serviceStubs; | ||
|
||
@Test | ||
public void testQuarkusManagedChannel() { | ||
Assertions.assertNull(serviceStubs.getOptions().getTarget()); | ||
Assertions.assertEquals("grpcHost:1234", serviceStubs.getOptions().getChannel().authority()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...eployment/src/test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelTest.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,35 @@ | ||
package io.quarkiverse.temporal.deployment; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.temporal.serviceclient.WorkflowServiceStubs; | ||
|
||
public class QuarkusManagedChannelTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource( | ||
new StringAsset( | ||
"quarkus.temporal.start-workers: false\n" + | ||
"quarkus.temporal.channel-type: quarkus-managed\n" + | ||
"quarkus.temporal.connection.target: customTarget:1234\n"), | ||
"application.properties")); | ||
|
||
@Inject | ||
WorkflowServiceStubs serviceStubs; | ||
|
||
@Test | ||
public void testQuarkusManagedChannel() { | ||
Assertions.assertNull(serviceStubs.getOptions().getTarget()); | ||
Assertions.assertEquals("customTarget:1234", serviceStubs.getOptions().getChannel().authority()); | ||
} | ||
} |
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
74 changes: 74 additions & 0 deletions
74
...sion/runtime/src/main/java/io/quarkiverse/temporal/TemporalConfigRelocateInterceptor.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,74 @@ | ||
package io.quarkiverse.temporal; | ||
|
||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
|
||
import io.smallrye.config.ConfigSourceInterceptor; | ||
import io.smallrye.config.ConfigSourceInterceptorContext; | ||
import io.smallrye.config.ConfigValue; | ||
|
||
public class TemporalConfigRelocateInterceptor implements ConfigSourceInterceptor { | ||
|
||
@Override | ||
public ConfigValue getValue(ConfigSourceInterceptorContext context, String name) { | ||
|
||
if (name.equals("quarkus.grpc.clients.temporal-client.host")) { | ||
|
||
ConfigValue host = context.proceed("quarkus.grpc.clients.temporal-client.host"); | ||
ConfigValue target = context.proceed("quarkus.temporal.connection.target"); | ||
if (host == null && target != null) { | ||
String[] split = target.getValue().split(":"); | ||
return target.from() | ||
.withName("quarkus.grpc.clients.temporal-client.host") | ||
.withValue(split[0]) | ||
.build(); | ||
} | ||
return host; | ||
} | ||
|
||
if (name.equals("quarkus.grpc.clients.temporal-client.port")) { | ||
|
||
ConfigValue port = context.proceed("quarkus.grpc.clients.temporal-client.port"); | ||
ConfigValue target = context.proceed("quarkus.temporal.connection.target"); | ||
if (port == null && target != null) { | ||
String[] split = target.getValue().split(":"); | ||
return target.from() | ||
.withName("quarkus.grpc.clients.temporal-client.port") | ||
.withValue(split[1]) | ||
.build(); | ||
} | ||
return port; | ||
} | ||
|
||
if (name.equals("quarkus.grpc.clients.temporal-client.test-port")) { | ||
|
||
ConfigValue port = context.proceed("quarkus.grpc.clients.temporal-client.test-port"); | ||
ConfigValue target = context.proceed("quarkus.temporal.connection.target"); | ||
if (port == null && target != null) { | ||
String[] split = target.getValue().split(":"); | ||
return target.from() | ||
.withName("quarkus.grpc.clients.temporal-client.test-port") | ||
.withValue(split[1]) | ||
.build(); | ||
} | ||
return port; | ||
} | ||
|
||
return context.proceed(name); | ||
} | ||
|
||
@Override | ||
public Iterator<String> iterateNames(ConfigSourceInterceptorContext context) { | ||
Set<String> names = new HashSet<>(); | ||
Iterator<String> iterator = context.iterateNames(); | ||
while (iterator.hasNext()) { | ||
names.add(iterator.next()); | ||
} | ||
names.add("quarkus.grpc.clients.temporal-client.host"); | ||
names.add("quarkus.grpc.clients.temporal-client.port"); | ||
names.add("quarkus.grpc.clients.temporal-client.test-port"); | ||
return names.iterator(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.