Package com.apple.foundationdb
Interface ReadTransactionContext
-
- All Known Subinterfaces:
Database
,ReadTransaction
,Tenant
,Transaction
,TransactionContext
public interface ReadTransactionContext
A context in which aReadTransaction
is 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 runFunction
s multiple times (retry) when certain errors are encountered. Therefore aFunction
should be prepared to be called more than once. This consideration means that aFunction
should use caution when directly modifying state in a class, especially in a way that could be observed were thatFunction
to not complete successfully.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.Executor
getExecutor()
Retrieves theExecutor
used by thisTransactionContext
when running asynchronous callbacks.<T> T
read(java.util.function.Function<? super ReadTransaction,T> retryable)
Runs a function in this context that takes a read-only transaction.<T> java.util.concurrent.CompletableFuture<T>
readAsync(java.util.function.Function<? super ReadTransaction,? extends java.util.concurrent.CompletableFuture<T>> retryable)
Runs a function in this context that takes a read-only transaction.
-
-
-
Method Detail
-
read
<T> T read(java.util.function.Function<? super ReadTransaction,T> retryable)
Runs a function in this context that takes a read-only 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 aReadTransaction
in this context- Returns:
- a result of the last call to
retryable
-
readAsync
<T> java.util.concurrent.CompletableFuture<T> readAsync(java.util.function.Function<? super ReadTransaction,? extends java.util.concurrent.CompletableFuture<T>> retryable)
Runs a function in this context that takes a read-only 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 aCompletableFuture
that will be set when the process is complete.- Type Parameters:
T
- the return type ofretryable
- Parameters:
retryable
- the block of logic to execute against aReadTransaction
in this context- Returns:
- a
CompletableFuture
that will be set to the value returned by the last call toretryable
-
getExecutor
java.util.concurrent.Executor getExecutor()
Retrieves theExecutor
used by thisTransactionContext
when running asynchronous callbacks.- Returns:
- the
Executor
used by thisTransactionContext
-
-