Skip to content

Commit

Permalink
config remapping
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanibus committed Sep 15, 2024
1 parent 33ce1b2 commit d0aa81f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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;
}

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");
return names.iterator();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.quarkiverse.temporal.TemporalConfigRelocateInterceptor
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

import static io.quarkiverse.temporal.Constants.TEMPORAL_TESTING_CAPABILITY;

import io.grpc.Channel;
import io.temporal.common.context.ContextPropagator;
import io.temporal.common.interceptors.WorkflowClientInterceptor;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Any;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Singleton;

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassType;
import org.jboss.jandex.ParameterizedType;

import io.quarkiverse.temporal.deployment.TemporalProcessor;
import io.quarkiverse.temporal.deployment.WorkflowClientBuildItem;
import io.quarkiverse.temporal.test.TestWorkflowRecorder;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
Expand All @@ -24,9 +21,10 @@
import io.quarkus.deployment.builditem.CapabilityBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.temporal.client.WorkflowClient;
import io.temporal.common.context.ContextPropagator;
import io.temporal.common.interceptors.WorkflowClientInterceptor;
import io.temporal.testing.TestWorkflowEnvironment;
import io.temporal.worker.WorkerFactory;
import org.jboss.jandex.ParameterizedType;

public class TemporalTestProcessor {

Expand Down Expand Up @@ -86,4 +84,4 @@ SyntheticBeanBuildItem produceWorkerFactorySyntheticBean(
.setRuntimeInit()
.done();
}
}
}

0 comments on commit d0aa81f

Please sign in to comment.