Package com.apple.foundationdb
Interface TransactionContext
-
- All Superinterfaces:
ReadTransactionContext
- All Known Subinterfaces:
Database,Tenant,Transaction
public interface TransactionContext extends ReadTransactionContext
A context in which aTransactionis available for database operations. The behavior of the methods specified in this interface, especially in the face errors, is implementation specific. In particular, some implementations will runFunctions multiple times (retry) when certain errors are encountered. Therefore aFunctionshould be prepared to be called more than once. This consideration means that aFunctionshould use caution when directly modifying state in a class, especially in a way that could be observed were thatFunctionto not complete successfully.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> Trun(java.util.function.Function<? super Transaction,T> retryable)Runs a function in this context that takes a transaction.<T> java.util.concurrent.CompletableFuture<T>runAsync(java.util.function.Function<? super Transaction,? extends java.util.concurrent.CompletableFuture<T>> retryable)Runs a function in this context that takes a transaction.-
Methods inherited from interface com.apple.foundationdb.ReadTransactionContext
getExecutor, read, readAsync
-
-
-
-
Method Detail
-
run
<T> T run(java.util.function.Function<? super Transaction,T> retryable)
Runs a function in this context that takes a transaction. Depending on the type of context, this may execute the supplied function multiple times if an error is encountered. This method is blocking -- control will not return from this call until work is complete.- Type Parameters:
T- the return type ofretryable- Parameters:
retryable- the block of logic to execute against aTransactionin this context- Returns:
- a result of the last call to
retryable
-
runAsync
<T> java.util.concurrent.CompletableFuture<T> runAsync(java.util.function.Function<? super Transaction,? extends java.util.concurrent.CompletableFuture<T>> retryable)
Runs a function in this context that takes a transaction. Depending on the type of context, this may execute the supplied function multiple times if an error is encountered. This call is non-blocking -- control flow will return immediately with aCompletableFuturethat will be set when the process is complete.- Type Parameters:
T- the return type ofretryable- Parameters:
retryable- the block of logic to execute against aTransactionin this context- Returns:
- a
CompletableFuturethat will be set to the value returned by the last call toretryable
-
-