Class RetryablePropertySourceImporter<D>
- Type Parameters:
D- The importer-specific declaration type
- All Implemented Interfaces:
PropertySourceImporter<RetryablePropertySourceImporter.RetryableImportDeclaration<D>>, Toggleable, AutoCloseable
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 attemptsretry-count– alias forretry-attemptsretry-delay– delay between attemptsretry-max-delay– maximum overall retry delayretry-multiplier– delay multiplierretry-jitter– jitter factor from0.0to1.0
- Since:
- 5.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRetry-aware wrapper around an importer-specific declaration.Nested classes/interfaces inherited from interface PropertySourceImporter
PropertySourceImporter.ImportContext<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringQuery or map property name for maximum retry attempts.static final StringAlias forRETRY_ATTEMPTS.static final StringQuery or map property name for the delay between attempts.static final StringQuery or map property name for retry jitter.static final StringQuery or map property name for the maximum overall retry delay.static final StringQuery or map property name for the retry multiplier. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a retryable importer backed by an internal single-threaded scheduler.protectedRetryablePropertySourceImporter(RetryOperationsFactory retryOperationsFactory) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Close resources associated with this importer after a configuration loading cycle completes.protected voidHook invoked from the finalclose()implementation before any internally-created scheduler is shut down.final Optional<PropertySource> importPropertySource(PropertySourceImporter.ImportContext<RetryablePropertySourceImporter.RetryableImportDeclaration<D>> context) Resolve a property source from the provided context.protected abstract Optional<PropertySource> Imports a property source using the importer-specific declaration.newImportDeclaration(ConvertibleValues<Object> values) Convert structured config import values into a type-safe import declaration consumed by this importer.protected abstract DnewImportDeclaration(ConvertibleValues<Object> values, RetryPolicy retryPolicy) Creates the importer-specific declaration from a structured import map.newImportDeclaration(ConnectionString connectionString) Convert the raw connection string into a type-safe import declaration consumed by this importer.protected abstract DnewImportDeclaration(ConnectionString connectionString, RetryPolicy retryPolicy) Creates the importer-specific declaration from a scalar connection-string import.protected RetryPolicyresolveRetryPolicy(ConvertibleValues<?> values) Resolves retry settings from connection-string options or map values.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertySourceImporter
getProviderMethods inherited from interface Toggleable
isEnabled
-
Field Details
-
RETRY_ATTEMPTS
Query or map property name for maximum retry attempts.- See Also:
-
RETRY_COUNT
-
RETRY_DELAY
Query or map property name for the delay between attempts.- See Also:
-
RETRY_MAX_DELAY
Query or map property name for the maximum overall retry delay.- See Also:
-
RETRY_MULTIPLIER
Query or map property name for the retry multiplier.- See Also:
-
RETRY_JITTER
-
-
Constructor Details
-
RetryablePropertySourceImporter
protected RetryablePropertySourceImporter()Creates a retryable importer backed by an internal single-threaded scheduler. -
RetryablePropertySourceImporter
- 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:PropertySourceImporterConvert the raw connection string into a type-safe import declaration consumed by this importer.Micronaut invokes this method once for each scalar
micronaut.config.importentry before callingPropertySourceImporter.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:
newImportDeclarationin interfacePropertySourceImporter<D>- Parameters:
connectionString- The parsed connection string declaration- Returns:
- The typed import declaration
-
newImportDeclaration
public final RetryablePropertySourceImporter.RetryableImportDeclaration<D> newImportDeclaration(ConvertibleValues<Object> values) Description copied from interface:PropertySourceImporterConvert structured config import values into a type-safe import declaration consumed by this importer.Micronaut invokes this method for map-based
micronaut.config.importdeclarations after resolving the requiredproviderfield. Implementations should validate required keys and throw a configuration exception if the declaration is invalid.- Specified by:
newImportDeclarationin interfacePropertySourceImporter<D>- Parameters:
values- The structured config import values- Returns:
- The typed import declaration
-
importPropertySource
public final Optional<PropertySource> importPropertySource(PropertySourceImporter.ImportContext<RetryablePropertySourceImporter.RetryableImportDeclaration<D>> context) Description copied from interface:PropertySourceImporterResolve a property source from the provided context.- Specified by:
importPropertySourcein interfacePropertySourceImporter<D>- Parameters:
context- The import context- Returns:
- The imported property source
-
close
public final void close()Description copied from interface:PropertySourceImporterClose 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. Implementations may override it to release per-load resources. The default implementation is a no-op.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacePropertySourceImporter<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 stringretryPolicy- 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 valuesretryPolicy- 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 finalclose()implementation before any internally-created scheduler is shut down.The default implementation is a no-op.
-
resolveRetryPolicy
Resolves retry settings from connection-string options or map values.- Parameters:
values- The import values- Returns:
- The resolved retry policy
-