Class CortexRestoreAutoConfiguration

java.lang.Object
ai.chatur.cortex.spring.backup.CortexRestoreAutoConfiguration

@AutoConfiguration(after={CortexAutoConfiguration.class,CortexS3AutoConfiguration.class}) @ConditionalOnProperty(prefix="cortex.restore", name="enabled", havingValue="true") @EnableConfigurationProperties(CortexProperties.class) @Import(ai.chatur.cortex.spring.backup.RestoreExecutionConfiguration.class) public class CortexRestoreAutoConfiguration extends Object
Restore-on-startup auto-configuration for Cortex: downloads the most recent backup from S3 and loads it into the assertions store before the application serves traffic, so a replaced instance on a fresh volume comes up with its data.

The inverse of CortexBackupAutoConfiguration, and a deliberately independent switch from it, in the same way CortexS3AutoConfiguration is independent: an instance may restore without scheduling backups of its own, or take backups without restoring. It treats S3 as the source of truth and the local store as replaceable — the restore is a wipe-and-load that runs on every boot (see RestoreService). A bucket with no backup is not an error; a first-ever deployment starts empty.

Off by default, and like backups it cannot simply be switched on: it needs cortex.persistent=true, an enabled and configured CortexProperties.S3 client, and the software.amazon.awssdk:s3 and software.amazon.awssdk:apache-client dependencies the starter does not bring. Every requirement is checked in this class's constructor, so a half-configured restore fails the context at startup naming what is missing rather than silently booting with an empty graph the operator expected to be seeded.

The bean touching the AWS SDK lives in the imported RestoreExecutionConfiguration, behind @ConditionalOnClass, and the S3 client itself in CortexS3AutoConfiguration. This class names neither the SDK in a method signature — otherwise a missing optional dependency would surface as a NoClassDefFoundError while Spring introspects this class, pre-empting the explanation the constructor is here to give.

  • Constructor Details

    • CortexRestoreAutoConfiguration

      public CortexRestoreAutoConfiguration(CortexProperties properties)
      Creates the auto-configuration, validating that a restore can actually run.
      Parameters:
      properties - the Cortex configuration properties
      Throws:
      IllegalStateException - if the assertions are not persistent, if the AWS SDK is missing from the classpath, or if the S3 client is disabled or unconfigured