C# Class FoundationDB.Client.Fdb

Show file Open project: BedeGaming/foundationdb-dotnet-client Class Usage Examples

Private Properties

Property Type Description
CreateClusterInternalAsync Task
DieOnError void
EnsureIsStarted void
EnsureNotOnNetworkThread void
EventLoop void
FailCannotExecuteOnNetworkThread void
OpenInternalAsync Task
SetNetworkOption FdbError
SetNetworkOption FdbError
StartEventLoop void
StopEventLoop void

Public Methods

Method Description
CreateClusterAsync ( CancellationToken cancellationToken ) : Task

Opens a connection to an existing FoundationDB cluster using the default cluster file

CreateClusterAsync ( string clusterFile, CancellationToken cancellationToken ) : Task

Opens a connection to an existing FDB Cluster

Failed ( FdbError code ) : bool

Returns true if the error code represents a failure

GetErrorMessage ( FdbError code ) : string

Return the error message matching the specified error code

GetMaxApiVersion ( ) : int

Returns the maximum API version currently supported by the installed client.

The version of the installed client (fdb_c.dll) can be different higher (or lower) than the version supported by this binding (FoundationDB.Client.dll)! If you want the highest possible version that is supported by both the binding and the client, you must call GetMaxSafeApiVersion. Attempts to select an API version higher than this value will fail.

GetMaxSafeApiVersion ( ) : int

Returns the maximum API version that is supported by both this binding and the installed client.

This value can be lower than the value returned by GetMaxApiVersion if the FoundationDB client installed on this machine is more recent that the version of this assembly. Using this version may break your application if new features change the behavior of the client (ex: default mode for snapshot transactions between v2.x and v3.x).

GetMinApiVersion ( ) : int

Returns the minimum API version currently supported by this binding.

Attempts to select an API version lower than this value will fail.

MapToException ( FdbError code ) : Exception

Maps an error code into an Exception (to be throwned)

OpenAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task

Create a new connection with the "DB" database on the cluster specified by the default cluster file.

Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.

OpenAsync ( FdbSubspace globalSpace, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Create a new connection with the "DB" database on the cluster specified by the default cluster file, and with the specified global subspace

Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.

OpenAsync ( string clusterFile, string dbName, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Create a new connection with a database on the specified cluster

As of 1.0, the only supported database name is "DB"Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.

OpenAsync ( string clusterFile, string dbName, FdbSubspace globalSpace, bool readOnly = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Create a new connection with a database on the specified cluster

As of 1.0, the only supported database name is 'DB'Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.

Start ( ) : void

Start the Network Thread, using the currently selected API version level

If you need a specific API version level, it must be defined by either calling UseApiVersion before calling this method, or by using the Start(int) override. Otherwise, the default API version will be selected.

Start ( int apiVersion ) : void

Select the API version level to use in this process, and start the Network Thread

Stop ( ) : void

Stop the Network Thread

Success ( FdbError code ) : bool

Returns true if the error code represents a success

UseApiVersion ( int value ) : void

Sets the desired API version of the binding. The selected version level may affect the availability and behavior or certain features.

The version can only be set before calling Fdb.Start() or any method that indirectly calls it. If you want to be on the bleeding edge, you can use GetMaxSafeApiVersion to get the maximum version supported by both this bindign and the FoundationDB client. If you want to be conservative, you should target a specific version level, and only change to newer versions after making sure that all tests are passing!

Private Methods

Method Description
CreateClusterInternalAsync ( string clusterFile, CancellationToken cancellationToken ) : Task
DieOnError ( FdbError code ) : void

Throws an exception if the code represents a failure

EnsureIsStarted ( ) : void

Ensure that we have loaded the C API library, and that the Network Thread has been started

EnsureNotOnNetworkThread ( [ callerMethod = null ) : void

Throws if the current thread is the Network Thread.

Should be used to ensure that we do not execute tasks continuations from the network thread, to avoid dead-locks.

EventLoop ( ) : void
FailCannotExecuteOnNetworkThread ( ) : void
OpenInternalAsync ( string clusterFile, string dbName, FdbSubspace globalSpace, bool readOnly, CancellationToken cancellationToken ) : Task

Create a new database handler instance using the specificied cluster file, database name, global subspace and read only settings

SetNetworkOption ( FdbNetworkOption option, Slice value ) : FdbError

Set the value of a network option on the database handler

SetNetworkOption ( FdbNetworkOption option, string value ) : FdbError

Set the value of a network option on the database handler

StartEventLoop ( ) : void

Starts the thread running the FDB event loop

StopEventLoop ( ) : void

Stops the thread running the FDB event loop

Method Details

CreateClusterAsync() public static method

Opens a connection to an existing FoundationDB cluster using the default cluster file
public static CreateClusterAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken Token used to abort the operation
return Task

CreateClusterAsync() public static method

Opens a connection to an existing FDB Cluster
public static CreateClusterAsync ( string clusterFile, CancellationToken cancellationToken ) : Task
clusterFile string Path to the 'fdb.cluster' file to use, or null for the default cluster file
cancellationToken System.Threading.CancellationToken Token used to abort the operation
return Task

Failed() public static method

Returns true if the error code represents a failure
public static Failed ( FdbError code ) : bool
code FdbError
return bool

GetErrorMessage() public static method

Return the error message matching the specified error code
public static GetErrorMessage ( FdbError code ) : string
code FdbError
return string

GetMaxApiVersion() public static method

Returns the maximum API version currently supported by the installed client.
The version of the installed client (fdb_c.dll) can be different higher (or lower) than the version supported by this binding (FoundationDB.Client.dll)! If you want the highest possible version that is supported by both the binding and the client, you must call GetMaxSafeApiVersion. Attempts to select an API version higher than this value will fail.
public static GetMaxApiVersion ( ) : int
return int

GetMaxSafeApiVersion() public static method

Returns the maximum API version that is supported by both this binding and the installed client.
This value can be lower than the value returned by GetMaxApiVersion if the FoundationDB client installed on this machine is more recent that the version of this assembly. Using this version may break your application if new features change the behavior of the client (ex: default mode for snapshot transactions between v2.x and v3.x).
public static GetMaxSafeApiVersion ( ) : int
return int

GetMinApiVersion() public static method

Returns the minimum API version currently supported by this binding.
Attempts to select an API version lower than this value will fail.
public static GetMinApiVersion ( ) : int
return int

MapToException() public static method

Maps an error code into an Exception (to be throwned)
public static MapToException ( FdbError code ) : Exception
code FdbError
return System.Exception

OpenAsync() public static method

Create a new connection with the "DB" database on the cluster specified by the default cluster file.
Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.
If the token is cancelled
public static OpenAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task
cancellationToken System.Threading.CancellationToken Token used to abort the operation
return Task

OpenAsync() public static method

Create a new connection with the "DB" database on the cluster specified by the default cluster file, and with the specified global subspace
Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.
If the token is cancelled
public static OpenAsync ( FdbSubspace globalSpace, CancellationToken cancellationToken = default(CancellationToken) ) : Task
globalSpace FdbSubspace Global subspace used as a prefix for all keys and layers
cancellationToken System.Threading.CancellationToken Token used to abort the operation
return Task

OpenAsync() public static method

Create a new connection with a database on the specified cluster
As of 1.0, the only supported database name is "DB" Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.
If is anything other than "DB" If the token is cancelled
public static OpenAsync ( string clusterFile, string dbName, CancellationToken cancellationToken = default(CancellationToken) ) : Task
clusterFile string Path to the 'fdb.cluster' file to use, or null for the default cluster file
dbName string Name of the database, or "DB" if not specified.
cancellationToken System.Threading.CancellationToken Cancellation Token
return Task

OpenAsync() public static method

Create a new connection with a database on the specified cluster
As of 1.0, the only supported database name is 'DB' Since connections are not pooled, so this method can be costly and should NOT be called every time you need to read or write from the database. Instead, you should open a database instance at the start of your process, and use it a singleton.
If is anything other than 'DB' If the token is cancelled
public static OpenAsync ( string clusterFile, string dbName, FdbSubspace globalSpace, bool readOnly = false, CancellationToken cancellationToken = default(CancellationToken) ) : Task
clusterFile string Path to the 'fdb.cluster' file to use, or null for the default cluster file
dbName string Name of the database. Must be 'DB'
globalSpace FdbSubspace Global subspace used as a prefix for all keys and layers
readOnly bool If true, the database instance will only allow read operations
cancellationToken System.Threading.CancellationToken Token used to abort the operation
return Task

Start() public static method

Start the Network Thread, using the currently selected API version level
If you need a specific API version level, it must be defined by either calling UseApiVersion before calling this method, or by using the Start(int) override. Otherwise, the default API version will be selected.
public static Start ( ) : void
return void

Start() public static method

Select the API version level to use in this process, and start the Network Thread
public static Start ( int apiVersion ) : void
apiVersion int
return void

Stop() public static method

Stop the Network Thread
public static Stop ( ) : void
return void

Success() public static method

Returns true if the error code represents a success
public static Success ( FdbError code ) : bool
code FdbError
return bool

UseApiVersion() public static method

Sets the desired API version of the binding. The selected version level may affect the availability and behavior or certain features.
The version can only be set before calling Fdb.Start() or any method that indirectly calls it. If you want to be on the bleeding edge, you can use GetMaxSafeApiVersion to get the maximum version supported by both this bindign and the FoundationDB client. If you want to be conservative, you should target a specific version level, and only change to newer versions after making sure that all tests are passing!
When attempting to change the API version after the binding has been started. When attempting to set a negative version, or a version that is either less or greater than the minimum and maximum supported versions.
public static UseApiVersion ( int value ) : void
value int
return void