Package io.lettuce.core.support
Interface AsyncObjectFactory<T>
-
- Type Parameters:
T
- Type of element managed in this factory.
public interface AsyncObjectFactory<T>
An interface defining life-cycle methods for instances to be served by an pool.- Since:
- 5.1
- Author:
- Mark Paluch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompletableFuture<T>
create()
Create an instance that can be served by the pool and wrap it in aPooledObject
to be managed by the pool.CompletableFuture<Void>
destroy(T object)
Destroys an instance no longer needed by the pool.CompletableFuture<Boolean>
validate(T object)
Ensures that the instance is safe to be returned by the pool.
-
-
-
Method Detail
-
create
CompletableFuture<T> create()
Create an instance that can be served by the pool and wrap it in aPooledObject
to be managed by the pool.- Returns:
- a
PooledObject
wrapping an instance that can be served by the pool
-
destroy
CompletableFuture<Void> destroy(T object)
Destroys an instance no longer needed by the pool.It is important for implementations of this method to be aware that there is no guarantee about what state
object
will be in and the implementation should be prepared to handle unexpected errors.Also, an implementation must take in to consideration that instances lost to the garbage collector may never be destroyed.
- Parameters:
object
- aPooledObject
wrapping the instance to be destroyed- See Also:
validate(T)
-
validate
CompletableFuture<Boolean> validate(T object)
Ensures that the instance is safe to be returned by the pool.- Parameters:
object
- aPooledObject
wrapping the instance to be validated- Returns:
false
ifobject
is not valid and should be dropped from the pool,true
otherwise.
-
-