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 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 io.micronaut.context.env.PropertySourceImporter
io.micronaut.context.env.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(io.micronaut.retry.RetryOperationsFactory retryOperationsFactory) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()protected voidHook invoked from the finalclose()implementation before any internally-created scheduler is shut down.final Optional<io.micronaut.context.env.PropertySource> importPropertySource(io.micronaut.context.env.PropertySourceImporter.ImportContext<RetryablePropertySourceImporter.RetryableImportDeclaration<D>> context) 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.newImportDeclaration(io.micronaut.core.convert.value.ConvertibleValues<Object> values) protected abstract DnewImportDeclaration(io.micronaut.core.convert.value.ConvertibleValues<Object> values, io.micronaut.retry.RetryPolicy retryPolicy) Creates the importer-specific declaration from a structured import map.newImportDeclaration(io.micronaut.core.util.ConnectionString connectionString) protected abstract DnewImportDeclaration(io.micronaut.core.util.ConnectionString connectionString, io.micronaut.retry.RetryPolicy retryPolicy) Creates the importer-specific declaration from a scalar connection-string import.protected io.micronaut.retry.RetryPolicyresolveRetryPolicy(io.micronaut.core.convert.value.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 io.micronaut.context.env.PropertySourceImporter
getProviderMethods inherited from interface io.micronaut.core.util.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
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:
newImportDeclarationin interfaceio.micronaut.context.env.PropertySourceImporter<D>
-
newImportDeclaration
public final RetryablePropertySourceImporter.RetryableImportDeclaration<D> newImportDeclaration(io.micronaut.core.convert.value.ConvertibleValues<Object> values) - Specified by:
newImportDeclarationin interfaceio.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:
importPropertySourcein interfaceio.micronaut.context.env.PropertySourceImporter<D>
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceio.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 stringretryPolicy- 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 valuesretryPolicy- 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 finalclose()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
-