IFdbDatabaseScopeProvider
Namespace: FoundationDB.Client · interface
Implements: IDisposable
Properties
Cancellation
CancellationToken Cancellation { get; }
Cancellation token that is tied to the lifetime of this scope
It will become cancelled if the scope (or one of its parents) is stopped.
IsAvailable
bool IsAvailable { get; }
If true, the database instance is ready. If false, the provider is either not started, or the connection is still pending.
Parent
IFdbDatabaseScopeProvider Parent { get; }
Returns the parent scope (or null if this is the top-level scope)
Root
FdbDirectorySubspaceLocation Root { get; }
Path to the root of the database
Methods
CreateScope
IFdbDatabaseScopeProvider<TState> CreateScope<TState>(Func<IFdbDatabase, CancellationToken, Task<(IFdbDatabase, TState)>> start, CancellationToken lifetime = null)
Create a scope that will use the database provided by this instance, and which also needs to perform some initialization steps before being ready (ex: using the DirectoryLayer to open subspaces, ...)
start— Handler that will be called AFTER the database becomes ready, but BEFORE any consumer of this scope can run.lifetime— Optional cancellation token that can be used to externally abort the new scope
GetDatabase
ValueTask<IFdbDatabase> GetDatabase(CancellationToken ct)
Returns the database instance, once it is ready
During the startup of the application, the task returned will wait until the database becomes ready. After that, the task will immediately return the database singleton.
TryGetDatabase
bool TryGetDatabase(out IFdbDatabase db)
Returns the database instance, if it is ready
db— Receives the database instance, if it is ready.
Returns: true if the database is ready; otherwise, false, in which case the caller should call GetDatabase and await the task.
This method is for advanced optimizations, that allows the caller to obtain the database handler in a non-async context, allowing the use of ReadOnlySpan or Span parameters.
Calling this will not attempt to auto-start the connection