/// <summary> /// Async factory method for constructing a new Session, creating a new session to QLDB on construction. /// </summary> /// /// <param name="ledgerName">The name of the ledger to create a session to.</param> /// <param name="sessionClient">The low-level session used for communication with QLDB.</param> /// <param name="logger">The logger to inject any logging framework.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>A newly created <see cref="Session"/>.</returns> internal static async Task <Session> StartSessionAsync( string ledgerName, IAmazonQLDBSession sessionClient, ILogger logger, CancellationToken cancellationToken) { var startSessionRequest = new StartSessionRequest { LedgerName = ledgerName, }; var request = new SendCommandRequest { StartSession = startSessionRequest, }; logger.LogDebug("Sending start session request: {}", request); var response = await sessionClient.SendCommandAsync(request, cancellationToken); return(new Session( ledgerName, sessionClient, response.StartSession.SessionToken, response.ResponseMetadata.RequestId, logger)); }
/// <summary> /// Initializes a new instance of the <see cref="QldbDriver"/> class. /// </summary> /// /// <param name="ledgerName">The ledger to create sessions to.</param> /// <param name="sessionClient">AWS SDK session client for QLDB.</param> /// <param name="maxConcurrentTransactions">The maximum number of concurrent transactions.</param> /// <param name="logger">The logger to use.</param> internal QldbDriver( string ledgerName, IAmazonQLDBSession sessionClient, int maxConcurrentTransactions, ILogger logger) { this.driverBase = new QldbDriverBase <QldbSession>(ledgerName, sessionClient, maxConcurrentTransactions, logger); }
internal QldbDriverBase( string ledgerName, IAmazonQLDBSession sessionClient, int maxConcurrentTransactions, ILogger logger) { this.LedgerName = ledgerName; this.SessionClient = sessionClient; this.Logger = logger; this.poolPermits = new SemaphoreSlim(maxConcurrentTransactions, maxConcurrentTransactions); this.sessionPool = new BlockingCollection <T>(maxConcurrentTransactions); }
/// <summary> /// Initializes a new instance of the <see cref="Session"/> class to a specific ledger. /// </summary> /// /// <param name="ledgerName">The name of the ledger to create a session to.</param> /// <param name="sessionClient">The low-level session used for communication with QLDB.</param> /// <param name="sessionToken">The unique identifying token for this session to QLDB.</param> /// <param name="sessionId">The initial request ID for this session to QLDB.</param> /// <param name="logger">The logger to inject any logging framework.</param> internal Session( string ledgerName, IAmazonQLDBSession sessionClient, string sessionToken, string sessionId, ILogger logger) { this.LedgerName = ledgerName; this.SessionClient = sessionClient; this.sessionToken = sessionToken; this.SessionId = sessionId; this.logger = logger; }
private Amazon.QLDBSession.Model.SendCommandResponse CallAWSServiceOperation(IAmazonQLDBSession client, Amazon.QLDBSession.Model.SendCommandRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon QLDB Session", "SendCommand"); try { #if DESKTOP return(client.SendCommand(request)); #elif CORECLR return(client.SendCommandAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
/// <summary> /// Factory method for constructing a new Session, creating a new session to QLDB on construction. /// </summary> /// /// <param name="ledgerName">The name of the ledger to create a session to.</param> /// <param name="sessionClient">The low-level session used for communication with QLDB.</param> /// <param name="logger">The logger to inject any logging framework.</param> /// /// <returns>A newly created <see cref="Session"/>.</returns> internal static Session StartSession(string ledgerName, IAmazonQLDBSession sessionClient, ILogger logger) { return (StartSessionAsync(ledgerName, sessionClient, logger, CancellationToken.None).GetAwaiter().GetResult()); }
protected override void ProcessRecord() { base.ProcessRecord(); Client = CreateClient(_CurrentCredentials, _RegionEndpoint); }