Skip to content

Commit

Permalink
Add global flag to disable dev services
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Aug 16, 2021
1 parent 278966b commit 3632979
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkus.deployment.dev.devservices;

import java.util.function.BooleanSupplier;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigRoot;

@ConfigRoot(name = "devservices")
public class GlobalDevServicesConfig {

/**
* Global flag that can be used to disable all Dev Services. If this is set to false then Dev Services will not be used.
*/
@ConfigItem(defaultValue = "true")
boolean enabled;

public static class Enabled implements BooleanSupplier {

final GlobalDevServicesConfig config;

public Enabled(GlobalDevServicesConfig config) {
this.config = config;
}

@Override
public boolean getAsBoolean() {
return config.enabled;
}
}
}
3 changes: 2 additions & 1 deletion docs/src/main/asciidoc/dev-services.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Quarkus will automatically start the relevant service (usually using https://www
application to use this service.

All this functionality is part of the Quarkus `deployment` modules, so does not affect the production application in any
way.
way. If you want to disable all Dev Services you can use the `quarkus.devservices.enabled=false` config property, although
in most cases this is not necessary as simply configuring the service will result in the Dev Service being disabled automatically.

This page lists all the Dev Services that Quarkus supports.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.runtime.configuration.ConfigUtils;

/**
Expand All @@ -35,7 +36,7 @@ public class DevServicesApicurioRegistryProcessor {

private final IsDockerWorking isDockerWorking = new IsDockerWorking(true);

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public void startApicurioRegistryDevService(ApicurioRegistryDevServicesBuildTimeConfig apicurioRegistryDevServices,
BuildProducer<DevServicesConfigResultBuildItem> devServicesConfiguration) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.runtime.LaunchMode;

Expand All @@ -42,7 +43,7 @@ public class DevServicesDatasourceProcessor {

private final IsDockerWorking isDockerWorking = new IsDockerWorking(true);

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
DevServicesDatasourceResultBuildItem launchDatabases(CurateOutcomeBuildItem curateOutcomeBuildItem,
List<DefaultDataSourceDbKindBuildItem> installedDrivers,
List<DevServicesDatasourceProviderBuildItem> devDBProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devservices.common.ContainerAddress;
import io.quarkus.devservices.common.ContainerLocator;
import io.quarkus.runtime.LaunchMode;
Expand Down Expand Up @@ -70,7 +71,7 @@ public class DevServicesKafkaProcessor {

private final IsDockerWorking isDockerWorking = new IsDockerWorking(true);

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public DevServicesKafkaBrokerBuildItem startKafkaDevService(
LaunchModeBuildItem launchMode,
KafkaBuildTimeConfig kafkaClientBuildTimeConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devservices.common.ConfigureUtil;
import io.quarkus.mongodb.runtime.MongodbConfig;
import io.quarkus.runtime.configuration.ConfigUtils;
Expand All @@ -41,7 +42,7 @@ public class DevServicesMongoProcessor {

private final IsDockerWorking isDockerWorking = new IsDockerWorking(true);

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public void startMongo(List<MongoConnectionNameBuildItem> mongoConnections,
MongoClientBuildTimeConfig mongoClientBuildTimeConfig,
Optional<DevServicesSharedNetworkBuildItem> devServicesSharedNetworkBuildItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.oidc.deployment.OidcBuildStep.IsEnabled;
import io.quarkus.oidc.deployment.devservices.OidcDevServicesBuildItem;
import io.quarkus.runtime.configuration.ConfigUtils;
Expand Down Expand Up @@ -78,7 +79,7 @@ public class KeycloakDevServicesProcessor {
private static volatile FileTime capturedRealmFileLastModifiedDate;
private final IsDockerWorking isDockerWorking = new IsDockerWorking(true);

@BuildStep(onlyIfNot = IsNormal.class, onlyIf = IsEnabled.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = { IsEnabled.class, GlobalDevServicesConfig.Enabled.class })
public KeycloakDevServicesConfigBuildItem startKeycloakContainer(
Optional<DevServicesSharedNetworkBuildItem> devServicesSharedNetworkBuildItem,
BuildProducer<DevServicesConfigResultBuildItem> devServices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devservices.common.ContainerLocator;
import io.quarkus.redis.client.deployment.RedisBuildTimeConfig.DevServiceConfiguration;
import io.quarkus.redis.client.runtime.RedisClientUtil;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class DevServicesRedisProcessor {
private static volatile Map<String, DevServiceConfiguration> capturedDevServicesConfiguration;
private static volatile boolean first = true;

@BuildStep(onlyIfNot = IsNormal.class, onlyIf = IsDockerRunningSilent.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = { IsDockerRunningSilent.class, GlobalDevServicesConfig.Enabled.class })
public void startRedisContainers(LaunchModeBuildItem launchMode,
Optional<DevServicesSharedNetworkBuildItem> devServicesSharedNetworkBuildItem,
BuildProducer<DevServicesConfigResultBuildItem> devConfigProducer, RedisBuildTimeConfig config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devservices.common.ContainerLocator;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ConfigUtils;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class DevServicesAmqpProcessor {

private final IsDockerWorking isDockerWorking = new IsDockerWorking(true);

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public DevServicesAmqpBrokerBuildItem startAmqpDevService(
LaunchModeBuildItem launchMode,
AmqpBuildTimeConfig amqpClientBuildTimeConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.runtime.configuration.ConfigUtils;
import io.quarkus.vault.runtime.VaultVersions;
import io.quarkus.vault.runtime.config.DevServicesConfig;
Expand All @@ -36,7 +37,7 @@ public class DevServicesVaultProcessor {
private static volatile boolean first = true;
private final IsDockerWorking isDockerWorking = new IsDockerWorking(true);

@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public void startVaultContainers(BuildProducer<DevServicesConfigResultBuildItem> devConfig, VaultBuildTimeConfig config) {

DevServicesConfig currentDevServicesConfiguration = config.devservices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,13 @@ public Integer get() {
}

public ThreadFactory createThreadFactory() {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
AtomicInteger threadCount = new AtomicInteger(0);
return runnable -> {
VertxThread thread = VertxThreadFactory.INSTANCE.newVertxThread(runnable,
"executor-thread-" + threadCount.getAndIncrement(), true, 0, null);
thread.setDaemon(true);
thread.setContextClassLoader(tccl);
return thread;
};
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/devmode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<configuration>
<skip>false</skip>
<systemPropertyVariables>
<quarkus.keycloak.devservices.enabled>false</quarkus.keycloak.devservices.enabled>
<quarkus.devservices.enabled>false</quarkus.devservices.enabled>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down

0 comments on commit 3632979

Please sign in to comment.