Skip to content

Commit

Permalink
Only add definitions updater cron when enabled (#20838)
Browse files Browse the repository at this point in the history
* Only add definitions updater cron when enabled

* Remove unused property
  • Loading branch information
gosusnp authored Jan 3, 2023
1 parent 177c13e commit 04e6566
Showing 1 changed file with 4 additions and 10 deletions.
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

0 comments on commit 04e6566

Please sign in to comment.