Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add devservice #71

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 75 additions & 3 deletions docs/modules/ROOT/pages/includes/quarkus-temporal.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,83 @@ h|[.header-title]##Configuration property##
h|Type
h|Default

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-devservice-enabled]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-devservice-enabled[`quarkus.temporal.devservice.enabled`]##

[.description]
--
Enable the Temporal Devservice.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_DEVSERVICE_ENABLED+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_DEVSERVICE_ENABLED+++`
endif::add-copy-button-to-env-var[]
--
|boolean
|`true`

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-devservice-image]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-devservice-image[`quarkus.temporal.devservice.image`]##

[.description]
--
The image to use for the Temporal Devservice.

Minimum supported version: `temporalio/auto-setup:1.24.3.0`


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_DEVSERVICE_IMAGE+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_DEVSERVICE_IMAGE+++`
endif::add-copy-button-to-env-var[]
--
|string
|`temporalio/auto-setup`

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-devservice-reuse]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-devservice-reuse[`quarkus.temporal.devservice.reuse`]##

[.description]
--
Whether to reuse the Temporal Devservice.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_DEVSERVICE_REUSE+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_DEVSERVICE_REUSE+++`
endif::add-copy-button-to-env-var[]
--
|boolean
|`true`

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-ui-url]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-ui-url[`quarkus.temporal.ui.url`]##

[.description]
--
The url of the Temporal UI.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_UI_URL+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_UI_URL+++`
endif::add-copy-button-to-env-var[]
--
|string
|

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-enable-mock]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-enable-mock[`quarkus.temporal.enable-mock`]##

[.description]
--
enable mock for testing
enable mock for testing.

If enabled, the Temporal devservice will not be started.


ifdef::add-copy-button-to-env-var[]
Expand Down Expand Up @@ -701,7 +773,7 @@ a| [[quarkus-temporal_quarkus-temporal-connection-target]] [.property-path]##lin

[.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[]
Expand All @@ -712,7 +784,7 @@ 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]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-connection-enable-https[`quarkus.temporal.connection.enable-https`]##

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,83 @@ h|[.header-title]##Configuration property##
h|Type
h|Default

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-devservice-enabled]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-devservice-enabled[`quarkus.temporal.devservice.enabled`]##

[.description]
--
Enable the Temporal Devservice.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_DEVSERVICE_ENABLED+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_DEVSERVICE_ENABLED+++`
endif::add-copy-button-to-env-var[]
--
|boolean
|`true`

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-devservice-image]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-devservice-image[`quarkus.temporal.devservice.image`]##

[.description]
--
The image to use for the Temporal Devservice.

Minimum supported version: `temporalio/auto-setup:1.24.3.0`


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_DEVSERVICE_IMAGE+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_DEVSERVICE_IMAGE+++`
endif::add-copy-button-to-env-var[]
--
|string
|`temporalio/auto-setup`

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-devservice-reuse]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-devservice-reuse[`quarkus.temporal.devservice.reuse`]##

[.description]
--
Whether to reuse the Temporal Devservice.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_DEVSERVICE_REUSE+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_DEVSERVICE_REUSE+++`
endif::add-copy-button-to-env-var[]
--
|boolean
|`true`

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-ui-url]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-ui-url[`quarkus.temporal.ui.url`]##

[.description]
--
The url of the Temporal UI.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_UI_URL+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_UI_URL+++`
endif::add-copy-button-to-env-var[]
--
|string
|

a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-enable-mock]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-enable-mock[`quarkus.temporal.enable-mock`]##

[.description]
--
enable mock for testing
enable mock for testing.

If enabled, the Temporal devservice will not be started.


ifdef::add-copy-button-to-env-var[]
Expand Down Expand Up @@ -701,7 +773,7 @@ a| [[quarkus-temporal_quarkus-temporal-connection-target]] [.property-path]##lin

[.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[]
Expand All @@ -712,7 +784,7 @@ 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]] [.property-path]##link:#quarkus-temporal_quarkus-temporal-connection-enable-https[`quarkus.temporal.connection.enable-https`]##

Expand Down
20 changes: 17 additions & 3 deletions extension/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,29 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-common-deployment</artifactId>
<artifactId>quarkus-grpc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-deployment</artifactId>
<artifactId>quarkus-smallrye-health-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health-spi</artifactId>
<artifactId>quarkus-devservices-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.temporal</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public class TemporalProcessor {

public static final DotName ACTIVITY_INTERFACE = DotName.createSimple(ActivityInterface.class);

private static final String FEATURE = "temporal";
public static final String FEATURE = "temporal";
public static final DotName CONTEXT_PROPAGATOR = DotName.createSimple(ContextPropagator.class);

@BuildStep
FeatureBuildItem feature() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.quarkiverse.temporal.deployment.devui;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

public class TemporalContainer extends GenericContainer<TemporalContainer> {

private static final Integer SERVER_EXPOSED_PORT = 7233;
private static final Integer UI_EXPOSED_PORT = 8233;
private final String path;

public TemporalContainer(DockerImageName dockerImageName, String path, Boolean reuse) {
super(dockerImageName);
this.path = path;

withCreateContainerCmdModifier(cmd -> {
cmd.withEntrypoint("/usr/local/bin/temporal");
cmd.withCmd(
"server", "start-dev",
"--ip", "0.0.0.0",
"--port", SERVER_EXPOSED_PORT.toString(),
"--ui-public-path", path);
})
.withExposedPorts(SERVER_EXPOSED_PORT, UI_EXPOSED_PORT)
.withReuse(reuse);
}

public TemporalContainer(String dockerImageName, String path, Boolean reuse) {
this(DockerImageName.parse(dockerImageName), path, reuse);
}

public String getUiUrl() {
return "http://" + getHost() + ":" + getMappedPort(UI_EXPOSED_PORT) + path;
}

public String getServerUrl() {
return getHost() + ":" + getMappedPort(SERVER_EXPOSED_PORT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,44 @@

import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

import io.quarkiverse.temporal.deployment.TemporalProcessor;
import io.quarkiverse.temporal.deployment.WorkerBuildItem;
import io.quarkiverse.temporal.deployment.WorkflowBuildItem;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.ExternalPageBuilder;
import io.quarkus.devui.spi.page.Page;
import io.quarkus.devui.spi.page.PageBuilder;
import io.quarkus.devui.spi.page.TableDataPageBuilder;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
import io.temporal.client.WorkflowClient;

/**
* Dev UI card for displaying important details such Temporal version.
*/
@BuildSteps(onlyIf = IsDevelopment.class)
public class TemporalDevUIProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
void createCard(BuildProducer<CardPageBuildItem> cardPageBuildItemBuildProducer, List<WorkflowBuildItem> workflows,
List<WorkerBuildItem> workers) {
@BuildStep
void createCard(
BuildProducer<CardPageBuildItem> cardPageBuildItemBuildProducer,
List<WorkflowBuildItem> workflows,
List<WorkerBuildItem> workers,
GlobalDevServicesConfig globalDevServicesConfig,
TemporalUiConfig uiConfig,
TemporalDevserviceConfig temporalDevserviceConfig,
ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig,
LaunchModeBuildItem launchMode,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem) {
final CardPageBuildItem card = new CardPageBuildItem();

final PageBuilder<ExternalPageBuilder> versionPage = Page.externalPageBuilder("Version")
Expand Down Expand Up @@ -58,11 +74,47 @@ void createCard(BuildProducer<CardPageBuildItem> cardPageBuildItemBuildProducer,
card.addBuildTimeData("workers",
workers.stream().map(WorkerBuildTimeData::new).collect(Collectors.toList()));

uiPage(uiConfig.url(), temporalDevserviceConfig, managementInterfaceBuildTimeConfig, launchMode,
nonApplicationRootPathBuildItem, card);

card.setCustomCard("qwc-temporal-card.js");

cardPageBuildItemBuildProducer.produce(card);
}

private void uiPage(
Optional<String> configPath,
TemporalDevserviceConfig temporalDevserviceConfig,
ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig,
LaunchModeBuildItem launchMode,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
CardPageBuildItem card) {
var path = configPath;

// check if the UI url is set in the config or if the devservice is enabled
if (!path.isPresent() && Boolean.TRUE.equals(temporalDevserviceConfig.enabled())) {
var defaultBasePath = nonApplicationRootPathBuildItem.resolveManagementPath(
TemporalProcessor.FEATURE,
managementInterfaceBuildTimeConfig,
launchMode);

path = Optional.of(defaultBasePath);
}

// if the path is not set, we don't have a UI to link to
if (!path.isPresent()) {
return;
}

// add the UI page
final PageBuilder<ExternalPageBuilder> uiPage = Page.externalPageBuilder("UI")
.icon("font-awesome-solid:desktop")
.url(path.get(), path.get())
.isHtmlContent();

card.addPage(uiPage);
}

static class WorkflowBuildTimeData {
WorkflowBuildTimeData(WorkflowBuildItem item) {
this.name = item.workflow.getName().replaceAll("\\B\\w+(\\.[a-z])", "$1");
Expand All @@ -88,7 +140,7 @@ static class WorkerBuildTimeData {
this.workflows = item.workflows.stream().map(workflow -> workflow.getName().replaceAll("\\B\\w+(\\.[a-z])", "$1"))
.collect(Collectors.toList());
this.activities = item.activities.stream()
.map(activities -> activities.getName().replaceAll("\\B\\w+(\\.[a-z])", "$1")).collect(Collectors.toList());
.map(activity -> activity.getName().replaceAll("\\B\\w+(\\.[a-z])", "$1")).collect(Collectors.toList());
}

private final String name;
Expand Down
Loading