public QldbDriver CreateDriver( AmazonQLDBSessionConfig amazonQldbSessionConfig, int maxConcurrentTransactions = default, string ledgerName = default) { QldbDriverBuilder builder = QldbDriver.Builder(); string finalLedgerName; if (ledgerName != default) { finalLedgerName = ledgerName; } else { finalLedgerName = this.ledgerName; } if (maxConcurrentTransactions != default) { builder.WithMaxConcurrentTransactions(maxConcurrentTransactions); } return(builder.WithQLDBSessionConfig(amazonQldbSessionConfig) .WithLedger(finalLedgerName) .Build()); }
/// <summary> /// Build a driver instance using the current configuration set with the builder. /// </summary> /// /// <returns>A newly created driver.</returns> public QldbDriver Build() { if (this.SessionConfig == null) { this.SessionConfig = new AmazonQLDBSessionConfig(); } this.SessionConfig.MaxErrorRetry = 0; this.sessionClient = this.Credentials == null ? new AmazonQLDBSessionClient(this.SessionConfig) : new AmazonQLDBSessionClient(this.Credentials, this.SessionConfig); this.sessionClient.BeforeRequestEvent += SetUserAgent; ValidationUtils.AssertStringNotEmpty(this.LedgerName, "ledgerName"); if (this.maxConcurrentTransactions == 0) { this.maxConcurrentTransactions = this.SessionConfig.GetType().GetProperty("MaxConnectionsPerServer") == null ? int.MaxValue : this.GetMaxConn(); } return(new QldbDriver( new SessionPool( () => Session.StartSession(this.LedgerName, this.sessionClient, this.Logger), CreateDefaultRetryHandler(this.logRetries ? this.Logger : null), this.maxConcurrentTransactions, this.Logger))); }
private IQldbDriver GetDriver() { AmazonQLDBSessionConfig sessionConfig = new AmazonQLDBSessionConfig(); sessionConfig.RegionEndpoint = RegionEndpoint.USEast1; return((IQldbDriver)PooledQldbDriver.Builder().WithAWSCredentials((AWSCredentials)this.awsCredentials).WithQLDBSessionConfig(sessionConfig).WithLedger(Global.LedgerName).Build()); }
public QldbService() { AmazonQLDBSessionConfig amazonQldbSessionConfig = new AmazonQLDBSessionConfig(); this.driver = QldbDriver.Builder() .WithQLDBSessionConfig(amazonQldbSessionConfig) .WithLedger(LedgerName) .Build(); }
public static AmazonQLDBSessionConfig CreateAmazonQLDBSessionConfig(string region) { var amazonQLDBSessionConfig = new AmazonQLDBSessionConfig(); if (region != null) { amazonQLDBSessionConfig.RegionEndpoint = RegionEndpoint.GetBySystemName(region); } return(amazonQLDBSessionConfig); }
public static void SetUp(TestContext context) { // Get AWS configuration properties from .runsettings file. string region = context.Properties["region"].ToString(); amazonQldbSessionConfig = IntegrationTestBase.CreateAmazonQLDBSessionConfig(region); integrationTestBase = new IntegrationTestBase(Constants.LedgerName, region); integrationTestBase.RunForceDeleteLedger(); integrationTestBase.RunCreateLedger(); }
public void TestWithQLDBSessionConfigValidAndInvalidInputs() { QldbDriver driver; var config = new AmazonQLDBSessionConfig(); // Null config driver = builder.WithQLDBSessionConfig(null).Build(); Assert.IsNotNull(driver); driver = builder.WithQLDBSessionConfig(config).Build(); Assert.IsNotNull(driver); }
static void Main(string[] args) { AmazonQLDBSessionConfig config = new AmazonQLDBSessionConfig(); string accessKey = "FILL_YOURS"; string secretKey = "FILL_YOURS"; var client = new Amazon.QLDBSession.AmazonQLDBSessionClient(accessKey, secretKey, RegionEndpoint.USEast2); var req = new Amazon.QLDBSession.Model.SendCommandRequest() { }; req.StartSession = new Amazon.QLDBSession.Model.StartSessionRequest(); req.StartSession.LedgerName = "ApexQA"; var ssResult = client.SendCommandAsync(req).Result; var sto = ssResult.StartSession.SessionToken; req = new Amazon.QLDBSession.Model.SendCommandRequest() { }; req.SessionToken = sto; req.StartTransaction = new Amazon.QLDBSession.Model.StartTransactionRequest(); ssResult = client.SendCommandAsync(req).Result; var txId = ssResult.StartTransaction.TransactionId; //req.StartTransaction req = new Amazon.QLDBSession.Model.SendCommandRequest() { }; req.SessionToken = sto; req.ExecuteStatement = new Amazon.QLDBSession.Model.ExecuteStatementRequest(); req.ExecuteStatement.TransactionId = txId; req.ExecuteStatement.Statement = "Insert INTO AuditLogs { \'AuditId\' : 2 }"; ssResult = client.SendCommandAsync(req).Result; req = new Amazon.QLDBSession.Model.SendCommandRequest() { }; req.SessionToken = sto; req.CommitTransaction = new Amazon.QLDBSession.Model.CommitTransactionRequest(); req.CommitTransaction.TransactionId = txId; //Not sure what to fill in the Commit Digest req.CommitTransaction.CommitDigest = new MemoryStream(); //This errors out ssResult = client.SendCommandAsync(req).Result; }
protected IAmazonQLDBSession CreateClient(AWSCredentials credentials, RegionEndpoint region) { var config = new AmazonQLDBSessionConfig { RegionEndpoint = region }; Amazon.PowerShell.Utils.Common.PopulateConfig(this, config); this.CustomizeClientConfig(config); var client = new AmazonQLDBSessionClient(credentials, config); client.BeforeRequestEvent += RequestEventHandler; client.AfterResponseEvent += ResponseEventHandler; return(client); }
public static async Task SetUp(TestContext context) { // Get AWS configuration properties from .runsettings file. string region = context.Properties["region"].ToString(); const string ledgerName = "DotnetAsyncStatementExecution"; amazonQldbSessionConfig = IntegrationTestBase.CreateAmazonQLDBSessionConfig(region); integrationTestBase = new IntegrationTestBase(ledgerName, region); integrationTestBase.RunForceDeleteLedger(); integrationTestBase.RunCreateLedger(); qldbDriver = integrationTestBase.CreateAsyncDriver(amazonQldbSessionConfig, new ObjectSerializer()); // Create table. var query = $"CREATE TABLE {Constants.TableName}"; Assert.AreEqual(1, await ExecuteAndReturnRowCount(query)); Assert.IsTrue(await ConfirmTableExists(Constants.TableName)); }
public static void SetUp(TestContext context) { // Get AWS configuration properties from .runsettings file. string region = context.Properties["region"].ToString(); const string ledgerName = "DotnetStatementExecution"; amazonQldbSessionConfig = IntegrationTestBase.CreateAmazonQLDBSessionConfig(region); integrationTestBase = new IntegrationTestBase(ledgerName, region); integrationTestBase.RunForceDeleteLedger(); integrationTestBase.RunCreateLedger(); qldbDriver = integrationTestBase.CreateDriver(amazonQldbSessionConfig, new ObjectSerializer()); // Create table. var query = $"CREATE TABLE {Constants.TableName}"; var count = qldbDriver.Execute(txn => { var result = txn.Execute(query); var count = 0; foreach (var row in result) { count++; } return(count); }); Assert.AreEqual(1, count); var result = qldbDriver.ListTableNames(); foreach (var row in result) { Assert.AreEqual(Constants.TableName, row); } }
public static async Task SetUp(TestContext context) { // Get AWS configuration properties from .runsettings file. string region = context.Properties["region"].ToString(); amazonQldbSessionConfig = IntegrationTestBase.CreateAmazonQLDBSessionConfig(region); integrationTestBase = new IntegrationTestBase(Constants.LedgerName, region); integrationTestBase.RunForceDeleteLedger(); integrationTestBase.RunCreateLedger(); qldbDriver = integrationTestBase.CreateDriver(amazonQldbSessionConfig); // Create table. var query = $"CREATE TABLE {Constants.TableName}"; var count = await qldbDriver.Execute(async txn => { var result = await txn.Execute(query); var count = 0; await foreach (var row in result) { count++; } return(count); }); Assert.AreEqual(1, count); var result = await qldbDriver.ListTableNames(); foreach (var row in result) { Assert.AreEqual(Constants.TableName, row); } }
/// <summary> /// Specify the configuration that should be used for the driver's sessions. /// </summary> /// /// <param name="sessionConfig">The configuration to create a driver with.</param> /// /// <returns>This builder object.</returns> public QldbDriverBuilder WithQLDBSessionConfig(AmazonQLDBSessionConfig sessionConfig) { this.SessionConfig = sessionConfig; return(this); }
/// <summary> /// Specify the configuration that should be used for the driver's sessions. /// </summary> /// /// <param name="sessionConfig">The configuration to create a driver with.</param> /// /// <returns>This builder object.</returns> public TBuilder WithQLDBSessionConfig(AmazonQLDBSessionConfig sessionConfig) { this.SessionConfig = sessionConfig; return(this.BuilderInstance); }
public IAmazonQldbProviderConfigurator UseQldbSessionConfig(AmazonQLDBSessionConfig sessionConfig) { _sessionConfig = sessionConfig; CreateDriverFactory(); return(this); }