FdbLayerExtensions
Namespace: FoundationDB.Client · class
Set of helper methods for working with IFdbLayer instances
Methods
ReadAsync
static Task<TResult> ReadAsync<TState, TResult>(IFdbLayer<TState> layer, IFdbReadOnlyRetryable db, Func<IFdbReadOnlyTransaction, TState, Task<TResult>> handler, CancellationToken ct)
Run an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionhandler— Idempotent handler that will only read from the database, and may be retried if a recoverable error occurs.ct— Token used to cancel the operation
Returns: Result of the last successful execution of handler.
Any attempt to write or commit using the transaction will throw. Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
static Task ReadAsync<TState>(IFdbLayer<TState> layer, IFdbReadOnlyRetryable db, Func<IFdbReadOnlyTransaction, TState, Task> handler, CancellationToken ct)
Run an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionhandler— Idempotent handler that will only read from the database, and may be retried if a recoverable error occurs.ct— Token used to cancel the operation
Returns: Task that succeeds if no error occurred during execution of handler.
Since the method does not result any result, it should only be used to verify the content of the database. Any attempt to write or commit using the transaction will throw. Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
static Task<TResult> ReadAsync<TState, TOptions, TResult>(IFdbLayer<TState, TOptions> layer, IFdbReadOnlyRetryable db, TOptions options, Func<IFdbReadOnlyTransaction, TState, Task<TResult>> handler, CancellationToken ct)
Run an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionoptions— Parameter that is used when resolving this layerhandler— Idempotent handler that will only read from the database, and may be retried if a recoverable error occurs.ct— Token used to cancel the operation
Returns: Result of the last successful execution of handler.
Any attempt to write or commit using the transaction will throw. Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
static Task ReadAsync<TState, TOptions>(IFdbLayer<TState, TOptions> layer, IFdbReadOnlyRetryable db, TOptions options, Func<IFdbReadOnlyTransaction, TState, Task> handler, CancellationToken ct)
Run an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionoptions— Parameter that is used when resolving this layerhandler— Idempotent handler that will only read from the database, and may be retried if a recoverable error occurs.ct— Token used to cancel the operation
Returns: Task that succeeds if no error occurred during execution of handler.
Since the method does not result any result, it should only be used to verify the content of the database. Any attempt to write or commit using the transaction will throw. Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
ReadWriteAsync
static Task<TResult> ReadWriteAsync<TState, TResult>(IFdbLayer<TState> layer, IFdbRetryable db, Func<IFdbTransaction, TState, Task<TResult>> handler, CancellationToken ct)
Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionhandler— Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.ct— Token used to cancel the operation
Returns: Result of the last successful execution of handler.
You do not need to commit the transaction inside the handler, it will be done automatically! Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
static Task<TResult> ReadWriteAsync<TState, TOptions, TResult>(IFdbLayer<TState, TOptions> layer, IFdbRetryable db, TOptions options, Func<IFdbTransaction, TState, Task<TResult>> handler, CancellationToken ct)
Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionoptions— Parameter that is used when resolving this layerhandler— Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.ct— Token used to cancel the operation
Returns: Result of the last successful execution of handler.
You do not need to commit the transaction inside the handler, it will be done automatically! Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
WriteAsync
static Task WriteAsync<TState>(IFdbLayer<TState> layer, IFdbRetryable db, Action<IFdbTransaction, TState> handler, CancellationToken ct)
Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionhandler— Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.ct— Token used to cancel the operation
You do not need to commit the transaction inside the handler, it will be done automatically! Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
static Task WriteAsync<TState>(IFdbLayer<TState> layer, IFdbRetryable db, Func<IFdbTransaction, TState, Task> handler, CancellationToken ct)
Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionhandler— Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.ct— Token used to cancel the operation
You do not need to commit the transaction inside the handler, it will be done automatically! Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
static Task WriteAsync<TState, TOptions>(IFdbLayer<TState, TOptions> layer, IFdbRetryable db, TOptions options, Action<IFdbTransaction, TState> handler, CancellationToken ct)
Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionoptions— Parameter that is used when resolving this layerhandler— Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.ct— Token used to cancel the operation
You do not need to commit the transaction inside the handler, it will be done automatically! Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.
static Task WriteAsync<TState, TOptions>(IFdbLayer<TState, TOptions> layer, IFdbRetryable db, TOptions options, Func<IFdbTransaction, TState, Task> handler, CancellationToken ct)
Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.
layer— Layer that will be resolved using the transaction, and will be passed as the second argument tohandler.db— Database instance that will be used to start the transactionoptions— Parameter that is used when resolving this layerhandler— Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.ct— Token used to cancel the operation
You do not need to commit the transaction inside the handler, it will be done automatically! Given that the can run more than once, and that there is no guarantee that the transaction commits once it returns, you MUST NOT mutate any global state (counters, cache, global dictionary) inside this lambda! You must wait for the Task to complete successfully before updating the global state of the application.