Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Support task domains in the worker spring configuration #3553

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ public int getThreadCount(String taskName) {
String key = "conductor.worker." + taskName + ".threadCount";
return environment.getProperty(key, Integer.class, 0);
}

@Override
public String getDomain(String taskName) {
String key = "conductor.worker." + taskName + ".domain";
return environment.getProperty(key, String.class, null);
}
}
3 changes: 2 additions & 1 deletion client-spring/src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
conductor.client.rootUri=http://localhost:8080/api/
conductor.worker.hello.threadCount=100
conductor.worker.hello.threadCount=100
conductor.worker.hello_again.domain=test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.lang.reflect.Method;
import java.util.*;

import com.google.common.base.Strings;
import com.netflix.conductor.common.utils.EnvUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -42,6 +44,8 @@ public class AnnotatedWorkerExecutor {

private Map<String, Integer> workerToPollingInterval = new HashMap<>();

private Map<String, String> workerDomains = new HashMap<>();

private Map<String, Object> workerClassObjs = new HashMap<>();

private static Set<String> scannedPackages = new HashSet<>();
Expand Down Expand Up @@ -163,6 +167,14 @@ private void addMethod(WorkerTask annotation, Method method, Object bean) {
}
workerToPollingInterval.put(name, pollingInterval);

String domain = workerConfiguration.getDomain(name);
if(Strings.isNullOrEmpty(domain)) {
domain = annotation.domain();
}
if(!Strings.isNullOrEmpty(domain)) {
workerDomains.put(name, domain);
}

workerClassObjs.put(name, bean);
workerExecutors.put(name, method);
LOGGER.info(
Expand All @@ -187,10 +199,12 @@ public void startPolling() {
}

LOGGER.info("Starting workers with threadCount {}", workerToThreadCount);
LOGGER.info("Worker domains {}", workerDomains);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be combined into one log output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep this separate for the visibility and since its only printed once.


taskRunner =
new TaskRunnerConfigurer.Builder(taskClient, executors)
.withTaskThreadCount(workerToThreadCount)
.withTaskToDomain(workerDomains)
.build();

taskRunner.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ public int getPollingInterval(String taskName) {
public int getThreadCount(String taskName) {
return 0;
}

public String getDomain(String taskName) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@
int threadCount() default 1;

int pollingInterval() default 100;

String domain() default "";
}