Skip to content

Commit

Permalink
- Allow config of timeout and verify-ssl when creating default ApiCli…
Browse files Browse the repository at this point in the history
…ent in Spring AutoConfiguration

- Support both "pollingInterval" and "poll_interval" for consistency in Annotated workers config
  • Loading branch information
jmigueprieto committed Oct 9, 2024
1 parent feca902 commit 10e0a0e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.springframework.core.env.Environment;

import com.netflix.conductor.client.worker.Worker;
import com.netflix.conductor.sdk.workflow.executor.task.WorkerConfiguration;

class SpringWorkerConfiguration extends WorkerConfiguration {
Expand All @@ -26,7 +27,11 @@ public SpringWorkerConfiguration(Environment environment) {

@Override
public int getPollingInterval(String taskName) {
return getProperty(taskName, "pollingInterval", Integer.class, 0);
Integer pollingInterval = getProperty(taskName, "pollingInterval", Integer.class, 0);
if (pollingInterval == 0) {
pollingInterval = getProperty(taskName, Worker.PROP_POLL_INTERVAL, Integer.class, 0);
}
return pollingInterval;
}

@Override
Expand All @@ -36,7 +41,7 @@ public int getThreadCount(String taskName) {

@Override
public String getDomain(String taskName) {
return getProperty(taskName, "domain", String.class, null);
return getProperty(taskName, Worker.PROP_DOMAIN, String.class, null);
}

private <T> T getProperty(String taskName, String property, Class<T> type, T defaultValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,25 @@
@Slf4j
public class OrkesConductorClientAutoConfiguration {

// Keeping these for backwards compatibility
public static final String CONDUCTOR_SERVER_URL ="conductor.server.url";
public static final String CONDUCTOR_SECURITY_CLIENT_KEY_ID ="conductor.security.client.key-id";
public static final String CONDUCTOR_SECURITY_CLIENT_SECRET ="conductor.security.client.secret";
//TODO add more properties e.g.: ssl off, timeout settings, etc. and these should be client properties!!!

// Properties should be placed under "conductor.client"
public static final String CONDUCTOR_CLIENT_BASE_PATH = "conductor.client.basepath";
public static final String CONDUCTOR_CLIENT_KEY_ID = "conductor.client.key-id";
public static final String CONDUCTOR_CLIENT_SECRET = "conductor.client.secret";
public static final String CONDUCTOR_CLIENT_CONNECT_TIMEOUT = "conductor.client.timeout.connect";
public static final String CONDUCTOR_CLIENT_READ_TIMEOUT = "conductor.client.timeout.read";
public static final String CONDUCTOR_CLIENT_WRITE_TIMEOUT = "conductor.client.timeout.write";
public static final String CONDUCTOR_CLIENT_VERIFYING_SSL = "conductor.client.verifying-ssl";

@Bean
@ConditionalOnMissingBean
public ApiClient orkesConductorClient(Environment env) {
ApiClient.ApiClientBuilder builder = ApiClient.builder();

String basePath = env.getProperty(CONDUCTOR_CLIENT_BASE_PATH);
if (basePath == null) {
basePath = env.getProperty(CONDUCTOR_SERVER_URL);
Expand All @@ -60,7 +68,30 @@ public ApiClient orkesConductorClient(Environment env) {
secret = env.getProperty(CONDUCTOR_SECURITY_CLIENT_SECRET);
}

return new ApiClient(basePath, keyId, secret);
Long connectTimeout = env.getProperty(CONDUCTOR_CLIENT_CONNECT_TIMEOUT, Long.class);
if (connectTimeout != null) {
builder.connectTimeout(connectTimeout);
}

Long readTimeout = env.getProperty(CONDUCTOR_CLIENT_READ_TIMEOUT, Long.class);
if (readTimeout != null) {
builder.readTimeout(readTimeout);
}

Long writeTimeout = env.getProperty(CONDUCTOR_CLIENT_WRITE_TIMEOUT, Long.class);
if (writeTimeout != null) {
builder.writeTimeout(writeTimeout);
}

Boolean verifyingSsl = env.getProperty(CONDUCTOR_CLIENT_VERIFYING_SSL, Boolean.class);
if (verifyingSsl != null) {
builder.verifyingSsl(verifyingSsl);
}

return builder
.basePath(basePath)
.credentials(keyId, secret)
.build();
}

@Bean
Expand Down

0 comments on commit 10e0a0e

Please sign in to comment.