Skip to content

Commit

Permalink
Merge pull request #26 from quarkiverse/start_workers
Browse files Browse the repository at this point in the history
add config to start workers
  • Loading branch information
rmanibus authored Aug 12, 2024
2 parents 51f4985 + d5341ef commit 8073ce7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ SyntheticBeanBuildItem produceWorkerFactorySyntheticBean(
.done();
}

@BuildStep
@BuildStep(onlyIf = StartWorkers.class)
@Record(ExecutionTime.RUNTIME_INIT)
ServiceStartBuildItem startService(
ServiceStartBuildItem startWorkers(
InitializedWorkerFactoryBuildItem workerFactoryBuildItem,
WorkerFactoryRecorder workerFactoryRecorder,
ShutdownContextBuildItem shutdownContextBuildItem) {
Expand All @@ -275,4 +275,12 @@ public boolean getAsBoolean() {
}
}

public static class StartWorkers implements BooleanSupplier {
TemporalBuildtimeConfig config;

public boolean getAsBoolean() {
return config.startWorkers();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.quarkiverse.temporal.deployment;

import java.util.List;

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.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;
import io.temporal.worker.WorkerFactory;

class StartWorkersDisabledTest {

@RegisterExtension
static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
.setForcedDependencies(List.of(Dependency.of("io.quarkiverse.temporal", "quarkus-temporal-test", "999-SNAPSHOT")))
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource(
new StringAsset("quarkus.temporal.enable-mock: true\nquarkus.temporal.start-workers: false\n"),
"application.properties"));

@Inject
WorkerFactory factory;

@Test
public void testStartWorkersDisabled() {
Assertions.assertFalse(factory.isStarted());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkiverse.temporal.deployment;

import java.util.List;

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.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;
import io.temporal.worker.WorkerFactory;

class StartWorkersEnabledTest {

@RegisterExtension
static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
.setForcedDependencies(List.of(Dependency.of("io.quarkiverse.temporal", "quarkus-temporal-test", "999-SNAPSHOT")))
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource(new StringAsset("quarkus.temporal.enable-mock: true\n"), "application.properties"));

@Inject
WorkerFactory factory;

@Test
public void testStartWorker() {
Assertions.assertTrue(factory.isStarted());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ public interface TemporalBuildtimeConfig {
*/
@WithDefault("false")
Boolean enableMock();

/**
* enable mock for testing
*/
@WithDefault("true")
Boolean startWorkers();
}

0 comments on commit 8073ce7

Please sign in to comment.