Class RetryablePropertySourceImporter<D>

java.lang.Object
io.micronaut.discovery.config.RetryablePropertySourceImporter<D>
Type Parameters:
D - The importer-specific declaration type
All Implemented Interfaces:
PropertySourceImporter<RetryablePropertySourceImporter.RetryableImportDeclaration<D>>, Toggleable, AutoCloseable

public abstract class RetryablePropertySourceImporter<D> extends Object implements PropertySourceImporter<RetryablePropertySourceImporter.RetryableImportDeclaration<D>>
Abstract PropertySourceImporter implementation that standardizes retry-aware import declarations.

This base class makes it easier for distributed configuration importers to support the same retry settings for both scalar connection-string imports and structured map imports. The final interface methods parse the configured retry options into a typed RetryPolicy and delegate importer-specific behavior to protected template methods.

The following standard retry properties are supported:

  • retry-attempts – maximum number of attempts
  • retry-count – alias for retry-attempts
  • retry-delay – delay between attempts
  • retry-max-delay – maximum overall retry delay
  • retry-multiplier – delay multiplier
  • retry-jitter – jitter factor from 0.0 to 1.0
Since:
5.0
  • Field Details

  • Constructor Details

    • RetryablePropertySourceImporter

      protected RetryablePropertySourceImporter()
      Creates a retryable importer backed by an internal single-threaded scheduler.
    • RetryablePropertySourceImporter

      protected RetryablePropertySourceImporter(RetryOperationsFactory retryOperationsFactory)
      Parameters:
      retryOperationsFactory - Factory used to create retry operations for import execution
  • Method Details

    • newImportDeclaration

      public final RetryablePropertySourceImporter.RetryableImportDeclaration<D> newImportDeclaration(ConnectionString connectionString)
      Description copied from interface: PropertySourceImporter
      Convert the raw connection string into a type-safe import declaration consumed by this importer.

      Micronaut invokes this method once for each scalar micronaut.config.import entry before calling PropertySourceImporter.importPropertySource(ImportContext). Implementations should validate any importer-specific semantics here and return an immutable declaration value suitable for repeated reads within the same load cycle.

      Specified by:
      newImportDeclaration in interface PropertySourceImporter<D>
      Parameters:
      connectionString - The parsed connection string declaration
      Returns:
      The typed import declaration
    • newImportDeclaration

      Description copied from interface: PropertySourceImporter
      Convert structured config import values into a type-safe import declaration consumed by this importer.

      Micronaut invokes this method for map-based micronaut.config.import declarations after resolving the required provider field. Implementations should validate required keys and throw a configuration exception if the declaration is invalid.

      Specified by:
      newImportDeclaration in interface PropertySourceImporter<D>
      Parameters:
      values - The structured config import values
      Returns:
      The typed import declaration
    • importPropertySource

      Description copied from interface: PropertySourceImporter
      Resolve a property source from the provided context.
      Specified by:
      importPropertySource in interface PropertySourceImporter<D>
      Parameters:
      context - The import context
      Returns:
      The imported property source
    • close

      public final void close()
      Description copied from interface: PropertySourceImporter
      Close resources associated with this importer after a configuration loading cycle completes.

      Micronaut invokes this method once after startup loading finishes and once after each refresh load finishes, also when the load fails. The property sources the importer has returned have been copied by then. Implementations may override it to release per-load resources. The default implementation is a no-op.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface PropertySourceImporter<D>
    • newImportDeclaration

      protected abstract D newImportDeclaration(ConnectionString connectionString, RetryPolicy retryPolicy)
      Creates the importer-specific declaration from a scalar connection-string import.
      Parameters:
      connectionString - The parsed connection string
      retryPolicy - The resolved retry policy
      Returns:
      The importer-specific declaration
    • newImportDeclaration

      protected abstract D newImportDeclaration(ConvertibleValues<Object> values, RetryPolicy retryPolicy)
      Creates the importer-specific declaration from a structured import map.
      Parameters:
      values - The structured import values
      retryPolicy - The resolved retry policy
      Returns:
      The importer-specific declaration
    • importRetryablePropertySource

      protected abstract Optional<PropertySource> importRetryablePropertySource(PropertySourceImporter.ImportContext<D> context)
      Imports a property source using the importer-specific declaration.
      Parameters:
      context - The import context
      Returns:
      The imported property source, if one was resolved
    • closeRetryableImporter

      protected void closeRetryableImporter()
      Hook invoked from the final close() implementation before any internally-created scheduler is shut down.

      The default implementation is a no-op.

    • resolveRetryPolicy

      protected RetryPolicy resolveRetryPolicy(ConvertibleValues<?> values)
      Resolves retry settings from connection-string options or map values.
      Parameters:
      values - The import values
      Returns:
      The resolved retry policy