in src/main/java/com/google/cloud/run/kafkascaler/ConfigurationProvider.java [200:232]
SchedulingConfig selfSchedulingConfig() {
SchedulingConfig schedulingConfig = SELF_SCHEDULING_DISABLED_CONFIG;
String cycleSecondsEnvVar = envProvider.getEnv("CYCLE_SECONDS");
int cycleSeconds;
if (cycleSecondsEnvVar != null && !cycleSecondsEnvVar.isEmpty()) {
try {
cycleSeconds = Integer.parseInt(cycleSecondsEnvVar);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("CYCLE_SECONDS is specified but not a number.", e);
}
ImmutableSet<String> missingEnvVars =
getMissingEnvVars(
ImmutableSet.of(
"FULLY_QUALIFIED_CLOUD_TASKS_QUEUE_NAME", "INVOKER_SERVICE_ACCOUNT_EMAIL"));
if (!missingEnvVars.isEmpty()) {
throw new IllegalArgumentException(
"Environment variables "
+ String.join(",", missingEnvVars)
+ " are required when setting CYCLE_SECONDS.");
}
schedulingConfig =
new SchedulingConfig(
envProvider.getEnv("FULLY_QUALIFIED_CLOUD_TASKS_QUEUE_NAME"),
envProvider.getEnv("INVOKER_SERVICE_ACCOUNT_EMAIL"),
Duration.ofSeconds(cycleSeconds));
}
return schedulingConfig;
}