Skip to content

Only add definitions updater cron when enabled #20838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.airbyte.config.init.ApplyDefinitionsHelper;
import io.airbyte.config.init.RemoteDefinitionsProvider;
import io.airbyte.config.persistence.ConfigRepository;
import io.micronaut.context.annotation.Requires;
import io.micronaut.context.annotation.Value;
import io.micronaut.scheduling.annotation.Scheduled;
import jakarta.inject.Singleton;
Expand All @@ -25,36 +26,29 @@
*/
@Singleton
@Slf4j
@Requires(property = "airbyte.cron.update-definitions.enabled",
value = "true")
public class DefinitionsUpdater {

private final ConfigRepository configRepository;

private final boolean shouldUpdateDefinitions;

private final URI remoteCatalogUrl;
private final DeploymentMode deploymentMode;

public DefinitionsUpdater(final ConfigRepository configRepository,
final DeploymentMode deploymentMode,
@Value("${airbyte.remote-connector-catalog-url}") final String remoteCatalogUrl,
@Value("${airbyte.cron.update-definitions.enabled}") final boolean shouldUpdateDefinitions) {
@Value("${airbyte.remote-connector-catalog-url}") final String remoteCatalogUrl) {
log.info("Creating connector definitions updater");

this.configRepository = configRepository;
this.deploymentMode = deploymentMode;
this.remoteCatalogUrl = remoteCatalogUrl != null ? URI.create(remoteCatalogUrl) : null;
this.shouldUpdateDefinitions = shouldUpdateDefinitions;
}

@Trace(operationName = SCHEDULED_TRACE_OPERATION_NAME)
@Scheduled(fixedRate = "30s",
initialDelay = "1m")
void updateDefinitions() {
if (!shouldUpdateDefinitions) {
log.info("Connector definitions update disabled.");
return;
}

if (remoteCatalogUrl == null) {
log.warn("Tried to update definitions, but the remote catalog url is not set");
return;
Expand Down