PodDestructionProcessor class abstract
Processor that provides hooks into the pod destruction and cleanup lifecycle.
This processor enables custom cleanup logic, resource release, and finalization operations when pods are being destroyed by the container. It ensures proper resource management and graceful shutdown of pod instances.
Destruction Phases
The pod destruction process follows this sequence:
requiresDestruction()- Check if pod needs destruction processingprocessBeforeDestruction()- Pre-destruction cleanup and preparation@PreDestroymethod invocations- Destruction-aware interface callbacks
processAfterDestruction()- Post-destruction finalization- Resource cleanup and garbage collection eligibility
Resource Management
- Connection Cleanup: Close database connections, network sockets
- File Handling: Release file handles, temporary files
- Cache Eviction: Clear in-memory caches, release references
- External Integration: Notify external systems of pod destruction
- Statistics Finalization: Record final metrics, log destruction events
Example:
@Pod
class ResourceCleanupProcessor implements PodDestructionProcessor {
@override
Future<void> processBeforeDestruction(Object pod, Class podClass, String name) async {
if (pod is ConnectionHolder) {
await pod.closeAllConnections();
}
}
@override
Future<bool> requiresDestruction(Object pod, Class podClass, String name) async {
return pod is Disposable || pod is ConnectionHolder;
}
}
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
processAfterDestruction(
Object pod, Class podClass, String name) → Future< void> - Processes the pod after all destruction callbacks have completed.
-
processBeforeDestruction(
Object pod, Class podClass, String name) → Future< void> - Processes the pod before any destruction callbacks are invoked.
-
requiresDestruction(
Object pod, Class podClass, String name) → Future< bool> - Determines whether the pod requires destruction processing by this processor.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited