diff --git a/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc b/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc index 978982f..65a4abb 100644 --- a/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc +++ b/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc @@ -24,7 +24,7 @@ ifndef::add-copy-button-to-env-var[] Environment variable: `+++QUARKUS_TEMPORAL_ENABLE_MOCK+++` endif::add-copy-button-to-env-var[] --|boolean -|`false` +|`true` a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-start-workers]]`link:#quarkus-temporal_quarkus-temporal-start-workers[quarkus.temporal.start-workers]` @@ -630,7 +630,7 @@ a| [[quarkus-temporal_quarkus-temporal-connection-target]]`link:#quarkus-tempora [.description] -- -Sets a target string, which can be either a valid `NameResolver`-compliant URI, or an authority string. See `ManagedChannelBuilder++#++forTarget(String)` for more information about parameter format. Default is 127.0.0.1:7233 +Sets a target string, which can be either a valid `NameResolver`-compliant URI, or an authority string. See `ManagedChannelBuilder++#++forTarget(String)` for more information about parameter format. ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_CONNECTION_TARGET+++[] @@ -639,7 +639,7 @@ ifndef::add-copy-button-to-env-var[] Environment variable: `+++QUARKUS_TEMPORAL_CONNECTION_TARGET+++` endif::add-copy-button-to-env-var[] --|string -|`127.0.0.1:7233` +|required icon:exclamation-circle[title=Configuration property is required] a| [[quarkus-temporal_quarkus-temporal-connection-enable-https]]`link:#quarkus-temporal_quarkus-temporal-connection-enable-https[quarkus.temporal.connection.enable-https]` @@ -840,7 +840,7 @@ Environment variable: `+++QUARKUS_TEMPORAL_WORKFLOW_RETRIES_INITIAL_INTERVAL+++` endif::add-copy-button-to-env-var[] --|link:https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html[Duration] link:#duration-note-anchor-{summaryTableId}[icon:question-circle[title=More information about the Duration format]] -|`1s` +|`1S` a| [[quarkus-temporal_quarkus-temporal-workflow-retries-backoff-coefficient]]`link:#quarkus-temporal_quarkus-temporal-workflow-retries-backoff-coefficient[quarkus.temporal.workflow.retries.backoff-coefficient]` diff --git a/extension/deployment/pom.xml b/extension/deployment/pom.xml index 39b01ca..b80b31a 100644 --- a/extension/deployment/pom.xml +++ b/extension/deployment/pom.xml @@ -21,6 +21,20 @@ io.quarkus quarkus-grpc-common-deployment + + io.quarkus + quarkus-devservices-deployment + + + org.testcontainers + testcontainers + + + junit + junit + + + io.quarkiverse.temporal quarkus-temporal diff --git a/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalContainer.java b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalContainer.java new file mode 100644 index 0000000..919fbd8 --- /dev/null +++ b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalContainer.java @@ -0,0 +1,41 @@ +package io.quarkiverse.temporal.deployment.devui; + +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.utility.DockerImageName; + +// import io.quarkus.devservices.common.ConfigureUtil; + +public class TemporalContainer extends GenericContainer { + + private static final Integer SERVER_EXPOSED_PORT = 7233; + private static final Integer UI_EXPOSED_PORT = 8233; + + private final TemporalDevserviceConfig config; + private String serviceName; + // private String hostname; + + public TemporalContainer(DockerImageName dockerImageName, TemporalDevserviceConfig config) { + super(dockerImageName); + this.config = config; + this.serviceName = "temporal"; + } + + @Override + protected void configure() { + super.configure(); + + withCreateContainerCmdModifier(cmd -> { + cmd.withEntrypoint("/usr/local/bin/temporal"); + cmd.withCmd("server", "start-dev", "--ip", "0.0.0.0"); + }); + + withExposedPorts(SERVER_EXPOSED_PORT, UI_EXPOSED_PORT); + + withLabel("quarkus-devservice-temporal", serviceName); + + withReuse(config.reuse()); + + // hostname = ConfigureUtil.configureSharedNetwork(this, "temporal-" + serviceName); + } + +} diff --git a/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceConfig.java b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceConfig.java new file mode 100644 index 0000000..0ff0872 --- /dev/null +++ b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceConfig.java @@ -0,0 +1,36 @@ +package io.quarkiverse.temporal.deployment.devui; + +import io.quarkus.runtime.annotations.ConfigPhase; +import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; + +@ConfigMapping(prefix = "quarkus.temporal.devservice") +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +public interface TemporalDevserviceConfig { + + /** + * Enable the Temporal Devservice. + */ + @WithDefault("true") + Boolean enabled(); + + /** + * The image to use for the Temporal Devservice. + */ + @WithDefault("temporalio/auto-setup") + String image(); + + /** + * The version of the image to use for the Temporal Devservice. + */ + @WithDefault("latest") + String version(); + + /** + * Whether to reuse the Temporal Devservice. + */ + @WithDefault("true") + Boolean reuse(); + +} diff --git a/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceProcessor.java b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceProcessor.java new file mode 100644 index 0000000..c706399 --- /dev/null +++ b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/devui/TemporalDevserviceProcessor.java @@ -0,0 +1,41 @@ +package io.quarkiverse.temporal.deployment.devui; + +import java.util.Map; + +import org.testcontainers.utility.DockerImageName; + +import io.quarkus.deployment.IsNormal; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.BuildSteps; +import io.quarkus.deployment.builditem.DevServicesResultBuildItem; +import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig; +import io.quarkus.devservices.common.ContainerLocator; + +@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class }) +public class TemporalDevserviceProcessor { + + private static final Integer SERVER_EXPOSED_PORT = 7233; + private static final Integer UI_EXPOSED_PORT = 8233; + private static final String DEV_SERVICE_LABEL = "quarkus-devservice-temporal"; + private static final ContainerLocator containerLocator = new ContainerLocator(DEV_SERVICE_LABEL, SERVER_EXPOSED_PORT); + + @BuildStep + public void build(TemporalDevserviceConfig config, BuildProducer devServiceProducer) { + if (Boolean.FALSE.equals(config.enabled())) { + return; + } + + var imageStr = config.image() + ":" + config.version(); + var image = DockerImageName.parse(imageStr) + .asCompatibleSubstituteFor(imageStr); + + var serverContainer = new TemporalContainer(image, config); + serverContainer.start(); + + var serverPort = serverContainer.getMappedPort(SERVER_EXPOSED_PORT); + devServiceProducer.produce(new DevServicesResultBuildItem("temporal", serverContainer.getContainerId(), Map.of( + "quarkus.temporal.connection.target", "localhost:" + serverPort))); + } + +} diff --git a/extension/runtime/src/main/java/io/quarkiverse/temporal/config/ConnectionRuntimeConfig.java b/extension/runtime/src/main/java/io/quarkiverse/temporal/config/ConnectionRuntimeConfig.java index c97ca9d..e95ad58 100644 --- a/extension/runtime/src/main/java/io/quarkiverse/temporal/config/ConnectionRuntimeConfig.java +++ b/extension/runtime/src/main/java/io/quarkiverse/temporal/config/ConnectionRuntimeConfig.java @@ -11,9 +11,8 @@ public interface ConnectionRuntimeConfig { /** * Sets a target string, which can be either a valid {@link NameResolver}-compliant URI, or an * authority string. See {@link ManagedChannelBuilder#forTarget(String)} for more information - * about parameter format. Default is 127.0.0.1:7233 + * about parameter format. */ - @WithDefault("127.0.0.1:7233") String target(); /**