Class RetryablePropertySourceImporter<D>

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

public abstract class RetryablePropertySourceImporter<D> extends Object implements io.micronaut.context.env.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(io.micronaut.retry.RetryOperationsFactory retryOperationsFactory)
      Parameters:
      retryOperationsFactory - Factory used to create retry operations for import execution
  • Method Details

    • newImportDeclaration

      public final RetryablePropertySourceImporter.RetryableImportDeclaration<D> newImportDeclaration(io.micronaut.core.util.ConnectionString connectionString)
      Specified by:
      newImportDeclaration in interface io.micronaut.context.env.PropertySourceImporter<D>
    • newImportDeclaration

      public final RetryablePropertySourceImporter.RetryableImportDeclaration<D> newImportDeclaration(io.micronaut.core.convert.value.ConvertibleValues<Object> values)
      Specified by:
      newImportDeclaration in interface io.micronaut.context.env.PropertySourceImporter<D>
    • importPropertySource

      public final Optional<io.micronaut.context.env.PropertySource> importPropertySource(io.micronaut.context.env.PropertySourceImporter.ImportContext<RetryablePropertySourceImporter.RetryableImportDeclaration<D>> context)
      Specified by:
      importPropertySource in interface io.micronaut.context.env.PropertySourceImporter<D>
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface io.micronaut.context.env.PropertySourceImporter<D>
    • newImportDeclaration

      protected abstract D newImportDeclaration(io.micronaut.core.util.ConnectionString connectionString, io.micronaut.retry.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(io.micronaut.core.convert.value.ConvertibleValues<Object> values, io.micronaut.retry.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<io.micronaut.context.env.PropertySource> importRetryablePropertySource(io.micronaut.context.env.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 io.micronaut.retry.RetryPolicy resolveRetryPolicy(io.micronaut.core.convert.value.ConvertibleValues<?> values)
      Resolves retry settings from connection-string options or map values.
      Parameters:
      values - The import values
      Returns:
      The resolved retry policy