FdbTenant

Namespace: FoundationDB.Client · class

Implements: IFdbTenant, IFdbRetryable, IFdbReadOnlyRetryable, IDisposable

Properties

Cancellation

CancellationToken Cancellation { get; }

Returns a cancellation token that is linked with the lifetime of this database instance

The token will be cancelled if the database instance is disposed

Database

IFdbDatabase Database { get; }

Database instance that created this tenant

Name

FdbTenantName Name { get; }

Name of the tenant

StillAlive

bool StillAlive { get; }

Methods

BeginTransaction

IFdbTransaction BeginTransaction(FdbTransactionMode mode, CancellationToken ct, FdbOperationContext context = null)

Start a new transaction on this database

  • mode — Mode of the new transaction (read-only, read-write, ...)
  • ct — Optional cancellation token that can abort all pending async operations started by this transaction.
  • context — If not null, attach the new transaction to an existing context.

Returns: New transaction instance that can read from or write to the database.

You MUST call Dispose() on the transaction when you are done with it. You SHOULD wrap it in a 'using' statement to ensure that it is disposed in all cases.

using(var tr = db.BeginTransaction(CancellationToken.None)) { tr.Set(Slice.FromString("Hello"), Slice.FromString("World")); tr.Clear(Slice.FromString("OldValue")); await tr.CommitAsync(); }

Dispose

void Dispose()

Close this database instance, aborting any pending transaction that was created by this instance.

GetIdAsync

Task<long> GetIdAsync(CancellationToken ct)

Fetch the id of this tenant

ReadAsync

Task ReadAsync(Func<IFdbReadOnlyTransaction, Task> handler, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task ReadAsync(Func<IFdbReadOnlyTransaction, ValueTask> handler, CancellationToken ct)

Task<TResult> ReadAsync<TResult>(Func<IFdbReadOnlyTransaction, Task<TResult>> handler, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadAsync<TResult>(Func<IFdbReadOnlyTransaction, ValueTask<TResult>> handler, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task ReadAsync<TState>(TState state, Func<IFdbReadOnlyTransaction, TState, Task> handler, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — 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.

Task ReadAsync<TState>(TState state, Func<IFdbReadOnlyTransaction, TState, ValueTask> handler, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — 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.

Task<TResult> ReadAsync<TState, TResult>(TState state, Func<IFdbReadOnlyTransaction, TState, Task<TResult>> handler, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — 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.

Task<TResult> ReadAsync<TState, TResult>(TState state, Func<IFdbReadOnlyTransaction, TState, ValueTask<TResult>> handler, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — 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.

Task<TResult> ReadAsync<TResult>(Func<IFdbReadOnlyTransaction, Task<TResult>> handler, Action<IFdbReadOnlyTransaction, TResult> success, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadAsync<TIntermediate, TResult>(Func<IFdbReadOnlyTransaction, Task<TIntermediate>> handler, Func<IFdbReadOnlyTransaction, TIntermediate, TResult> success, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadAsync<TIntermediate, TResult>(Func<IFdbReadOnlyTransaction, ValueTask<TIntermediate>> handler, Func<IFdbReadOnlyTransaction, TIntermediate, TResult> success, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadAsync<TIntermediate, TResult>(Func<IFdbReadOnlyTransaction, Task<TIntermediate>> handler, Func<IFdbReadOnlyTransaction, TIntermediate, Task<TResult>> success, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadAsync<TIntermediate, TResult>(Func<IFdbReadOnlyTransaction, ValueTask<TIntermediate>> handler, Func<IFdbReadOnlyTransaction, TIntermediate, ValueTask<TResult>> success, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadAsync<TState, TIntermediate, TResult>(TState state, Func<IFdbReadOnlyTransaction, TState, Task<TIntermediate>> handler, Func<IFdbReadOnlyTransaction, TIntermediate, Task<TResult>> success, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — Idempotent handler that will only read from the database, and may be retried if a recoverable error occurs.
  • success — Handler that will be called once the transaction executes successfully. The result from the last invocation of handler will be passed as the second parameter.
  • ct — Token used to cancel the operation

Returns: Result return by success, if it was called.

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.

Task<TResult> ReadAsync<TState, TIntermediate, TResult>(TState state, Func<IFdbReadOnlyTransaction, TState, ValueTask<TIntermediate>> handler, Func<IFdbReadOnlyTransaction, TIntermediate, ValueTask<TResult>> success, CancellationToken ct)

Runs an idempotent transaction block inside a read-only transaction, which can be executed more than once if any retryable error occurs.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — Idempotent handler that will only read from the database, and may be retried if a recoverable error occurs.
  • success — Handler that will be called once the transaction executes successfully. The result from the last invocation of handler will be passed as the second parameter.
  • ct — Token used to cancel the operation

Returns: Result return by success, if it was called.

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

Task<TResult> ReadWriteAsync<TResult>(Func<IFdbTransaction, 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.

  • handler — 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.

Task<TResult> ReadWriteAsync<TResult>(Action<IFdbTransaction> handler, Func<IFdbTransaction, TResult> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully.
  • ct — Token used to cancel the operation

Returns: Result return by success, if it was called.

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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.

Task<TResult> ReadWriteAsync<TState, TResult>(TState state, 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.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — 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.

Task<TResult> ReadWriteAsync<TResult>(Func<IFdbTransaction, Task<TResult>> handler, Action<IFdbTransaction, TResult> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadWriteAsync<TResult>(Func<IFdbTransaction, Task> handler, Func<IFdbTransaction, Task<TResult>> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully.
  • ct — Token used to cancel the operation

Returns: Result return by success, if it was called.

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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.

Task<TResult> ReadWriteAsync<TResult>(Func<IFdbTransaction, Task> handler, Func<IFdbTransaction, TResult> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully.
  • ct — Token used to cancel the operation

Returns: Result return by success, if it was called.

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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.

Task<TResult> ReadWriteAsync<TIntermediate, TResult>(Func<IFdbTransaction, Task<TIntermediate>> handler, Func<IFdbTransaction, TIntermediate, TResult> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadWriteAsync<TIntermediate, TResult>(Func<IFdbTransaction, Task<TIntermediate>> handler, Func<IFdbTransaction, TIntermediate, Task<TResult>> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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.

Task<TResult> ReadWriteAsync<TState, TIntermediate, TResult>(TState state, Func<IFdbTransaction, TState, Task<TIntermediate>> handler, Func<IFdbTransaction, TIntermediate, Task<TResult>> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully. The intermediate result from the last invocation of handler will be passed as the seconde parameter.
  • ct — Token used to cancel the operation

Returns: Result return by success, if it was called.

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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.

WriteAsync

Task WriteAsync(Action<IFdbTransaction> handler, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — 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. Alternatively, you can call that supports a 'success' callback.

Task WriteAsync(Func<IFdbTransaction, 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.

  • handler — 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. Alternatively, you can call that supports a 'success' callback.

Task WriteAsync<TState>(TState state, 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.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — 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. Alternatively, you can call that supports a 'success' callback.

Task WriteAsync<TState>(TState state, 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.

  • state — Caller-provided context or state that will be passed through to the handler
  • handler — 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. Alternatively, you can call that supports a 'success' callback.

Task WriteAsync(Action<IFdbTransaction> handler, Action<IFdbTransaction> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully.
  • 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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.

Task WriteAsync(Action<IFdbTransaction> handler, Func<IFdbTransaction, Task> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully.
  • 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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.

Task WriteAsync(Func<IFdbTransaction, Task> handler, Action<IFdbTransaction> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully.
  • 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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.

Task WriteAsync(Func<IFdbTransaction, Task> handler, Func<IFdbTransaction, Task> success, CancellationToken ct)

Run an idempotent transaction block inside a writable transaction, which can be executed more than once if any retryable error occurs.

  • handler — Idempotent handler that will attempt to mutate the database, and may be retried until the transaction commits, or a non-recoverable error occurs.
  • success — Handler that will be called once the transaction commits successfully.
  • 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, and only inside the handler! Please note that there is NO guarantee that will be invoked even if the transaction commits successfully! The execution may be interrupted before the handler has time to execute.