Class QldbDriver
Represents a factory for accessing a specific ledger within QLDB. This class or AsyncQldbDriver should be the main entry points to any interaction with QLDB.
This factory pools sessions and attempts to return unused but available sessions when getting new sessions. The pool does not remove stale sessions until a new session is retrieved. The default pool size is the maximum amount of connections the session client allows set in the Amazon.Runtime.ClientConfig. Dispose() should be called when this factory is no longer needed in order to clean up resources, ending all sessions in the pool.
Inheritance
Inherited Members
Namespace: Amazon.QLDB.Driver
Assembly: Amazon.QLDB.Driver.dll
Syntax
public class QldbDriver : IQldbDriver, IDisposable
Methods
| Improve this Doc View SourceBuilder()
Retrieve a builder object for creating a QldbDriver.
Declaration
public static QldbDriverBuilder Builder()
Returns
Type | Description |
---|---|
QldbDriverBuilder | The builder object for creating a QldbDriver. |
Dispose()
Close this driver and end all sessions in the current pool. No-op if already closed.
Declaration
public void Dispose()
Execute(Action<TransactionExecutor>)
Start a session, then execute the Executor lambda against QLDB within a transaction where no result is expected, and end the session.
Declaration
public void Execute(Action<TransactionExecutor> action)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TransactionExecutor> | action | The Executor lambda with no return value representing the block of code to be executed within the transaction. This cannot have any side effects as it may be invoked multiple times. |
Exceptions
Type | Condition |
---|---|
TransactionAbortedException | Thrown if the Executor lambda calls Abort(). |
QldbDriverException | Thrown when called on a disposed instance. |
Amazon.Runtime.AmazonServiceException | Thrown when there is an error executing against QLDB. |
Execute(Action<TransactionExecutor>, RetryPolicy)
Start a session, then execute the Executor lambda against QLDB within a transaction where no result is expected, and end the session.
Declaration
public void Execute(Action<TransactionExecutor> action, RetryPolicy retryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TransactionExecutor> | action | The Executor lambda with no return value representing the block of code to be executed within the transaction. This cannot have any side effects as it may be invoked multiple times. |
RetryPolicy | retryPolicy | A RetryPolicy that overrides the RetryPolicy set when creating the driver. The given retry policy will be used when retrying the transaction. |
Exceptions
Type | Condition |
---|---|
TransactionAbortedException | Thrown if the Executor lambda calls Abort(). |
QldbDriverException | Thrown when called on a disposed instance. |
Amazon.Runtime.AmazonServiceException | Thrown when there is an error executing against QLDB. |
Execute(Action<TransactionExecutor>, Action<Int32>)
Start a session, then execute the Executor lambda against QLDB within a transaction where no result is expected, and end the session.
Declaration
[Obsolete("As of release 1.0, replaced by 'retryPolicy'. Will be removed in the next major release.")]
public void Execute(Action<TransactionExecutor> action, Action<int> retryAction)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TransactionExecutor> | action | The Executor lambda with no return value representing the block of code to be executed within the transaction. This cannot have any side effects as it may be invoked multiple times. |
System.Action<System.Int32> | retryAction | A lambda that is invoked when the Executor lambda is about to be retried due to a retriable error. Can be null if not applicable. |
Exceptions
Type | Condition |
---|---|
TransactionAbortedException | Thrown if the Executor lambda calls Abort(). |
QldbDriverException | Thrown when called on a disposed instance. |
Amazon.Runtime.AmazonServiceException | Thrown when there is an error executing against QLDB. |
Execute<T>(Func<TransactionExecutor, T>)
Start a session, then execute the Executor lambda against QLDB and retrieve the result within a transaction, and end the session.
Declaration
public T Execute<T>(Func<TransactionExecutor, T> func)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TransactionExecutor, T> | func | The Executor lambda representing the block of code to be executed within the transaction. This cannot have any side effects as it may be invoked multiple times, and the result cannot be trusted until the transaction is committed. |
Returns
Type | Description |
---|---|
T | The return value of executing the executor. Note that if you directly return a IResult, this will be automatically buffered in memory before the implicit commit to allow reading, as the commit will close any open results. Any other IResult instances created within the executor block will be invalidated, including if the return value is an object which nests said IResult instances within it. |
Type Parameters
Name | Description |
---|---|
T | The return type. |
Exceptions
Type | Condition |
---|---|
TransactionAbortedException | Thrown if the Executor lambda calls Abort(). |
QldbDriverException | Thrown when called on a disposed instance. |
Amazon.Runtime.AmazonServiceException | Thrown when there is an error executing against QLDB. |
Execute<T>(Func<TransactionExecutor, T>, RetryPolicy)
Start a session, then execute the Executor lambda against QLDB and retrieve the result within a transaction, and end the session.
Declaration
public T Execute<T>(Func<TransactionExecutor, T> func, RetryPolicy retryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TransactionExecutor, T> | func | The Executor lambda representing the block of code to be executed within the transaction. This cannot have any side effects as it may be invoked multiple times, and the result cannot be trusted until the transaction is committed. |
RetryPolicy | retryPolicy | A RetryPolicy that overrides the RetryPolicy set when creating the driver. The given retry policy will be used when retrying the transaction. |
Returns
Type | Description |
---|---|
T | The return value of executing the executor. Note that if you directly return a IResult, this will be automatically buffered in memory before the implicit commit to allow reading, as the commit will close any open results. Any other IResult instances created within the executor block will be invalidated, including if the return value is an object which nests said IResult instances within it. |
Type Parameters
Name | Description |
---|---|
T | The return type. |
Exceptions
Type | Condition |
---|---|
TransactionAbortedException | Thrown if the Executor lambda calls Abort(). |
QldbDriverException | Thrown when called on a disposed instance. |
Amazon.Runtime.AmazonServiceException | Thrown when there is an error executing against QLDB. |
Execute<T>(Func<TransactionExecutor, T>, Action<Int32>)
Start a session, then execute the Executor lambda against QLDB and retrieve the result within a transaction, and end the session.
Declaration
[Obsolete("As of release 1.0, replaced by 'retryPolicy'. Will be removed in the next major release.")]
public T Execute<T>(Func<TransactionExecutor, T> func, Action<int> retryAction)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TransactionExecutor, T> | func | The Executor lambda representing the block of code to be executed within the transaction. This cannot have any side effects as it may be invoked multiple times, and the result cannot be trusted until the transaction is committed. |
System.Action<System.Int32> | retryAction | A lambda that is invoked when the Executor lambda is about to be retried due to a retriable error. Can be null if not applicable. |
Returns
Type | Description |
---|---|
T | The return value of executing the executor. Note that if you directly return a IResult, this will be automatically buffered in memory before the implicit commit to allow reading, as the commit will close any open results. Any other IResult instances created within the executor block will be invalidated, including if the return value is an object which nests said IResult instances within it. |
Type Parameters
Name | Description |
---|---|
T | The return type. |
Exceptions
Type | Condition |
---|---|
TransactionAbortedException | Thrown if the Executor lambda calls Abort(). |
QldbDriverException | Thrown when called on a disposed instance. |
Amazon.Runtime.AmazonServiceException | Thrown when there is an error executing against QLDB. |
ListTableNames()
Retrieve the table names that are available within the ledger.
Declaration
public IEnumerable<string> ListTableNames()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | The Enumerable over the table names in the ledger. |