/// <summary>
        /// Initializes a new instance of <see cref="SpannerCommand"/>.
        /// </summary>
        /// <param name="commandTextBuilder">The <see cref="SpannerCommandTextBuilder"/>
        /// that configures the text of this command. Must not be null.</param>
        /// <param name="connection">The <see cref="SpannerConnection"/> that is
        /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
        /// <param name="transaction">An optional <see cref="SpannerTransaction"/>
        /// created through <see>
        /// <cref>SpannerConnection.BeginTransactionAsync</cref>
        /// </see>
        /// </param>. May be null.
        /// <param name="parameters">An optional collection of <see cref="SpannerParameter"/>
        /// that is used in the command. May be null.</param>
        public SpannerCommand(
            SpannerCommandTextBuilder commandTextBuilder,
            SpannerConnection connection,
            SpannerTransaction transaction        = null,
            SpannerParameterCollection parameters = null)
            : this(connection, transaction, parameters)
        {
            GaxPreconditions.CheckNotNull(commandTextBuilder, nameof(commandTextBuilder));
            GaxPreconditions.CheckNotNull(connection, nameof(connection));

            SpannerCommandTextBuilder = commandTextBuilder;
        }
Exemplo n.º 2
0
 private SpannerCommand(
     SpannerConnection connection,
     SpannerTransaction transaction,
     SpannerParameterCollection parameters) : this()
 {
     SpannerConnection = connection;
     _transaction      = transaction;
     if (parameters != null)
     {
         Parameters = parameters;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of <see cref="SpannerCommand"/> for a read operation.
 /// </summary>
 /// <remarks>
 /// The initial command timeout is taken from the options associated with <paramref name="connection"/>.
 /// </remarks>
 /// <param name="commandTextBuilder">The <see cref="SpannerCommandTextBuilder"/>
 /// that configures the text of this command. Must be a read command and not be null.</param>
 /// <param name="connection">The <see cref="SpannerConnection"/> that is
 /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
 /// <param name="keySet">The <see cref="KeySet"/> that is used to select rows. Must not be null.</param>
 /// <param name="transaction">An optional <see cref="SpannerTransaction"/>
 /// created through <see cref="SpannerConnection.BeginTransactionAsync" />. May be null.</param>
 internal SpannerCommand(
     SpannerCommandTextBuilder commandTextBuilder,
     SpannerConnection connection,
     KeySet keySet,
     SpannerTransaction transaction = null)
     : this(connection, transaction, null, null)
 {
     GaxPreconditions.CheckArgument(commandTextBuilder.SpannerCommandType == SpannerCommandType.Read,
                                    nameof(commandTextBuilder.SpannerCommandType), "KeySet is only allowed for Read commands");
     SpannerCommandTextBuilder = GaxPreconditions.CheckNotNull(commandTextBuilder, nameof(commandTextBuilder));
     KeySet = GaxPreconditions.CheckNotNull(keySet, nameof(keySet));
 }
Exemplo n.º 4
0
 internal SpannerDataReader(
     ReliableStreamReader resultSet,
     SpannerConnection connectionToClose = null,
     SingleUseTransaction singleUseTransaction = null)
 {
     GaxPreconditions.CheckNotNull(resultSet, nameof(resultSet));
     Logger.LogPerformanceCounter(
         "SpannerDataReader.ActiveCount",
         () => Interlocked.Increment(ref s_readerCount));
     _resultSet = resultSet;
     _connectionToClose = connectionToClose;
     _txToClose = singleUseTransaction;
 }
Exemplo n.º 5
0
 private SpannerCommand(
     SpannerConnection connection,
     SpannerTransaction transaction,
     SpannerParameterCollection parameters,
     CommandPartition commandPartition) : this(connection)
 {
     _transaction = transaction;
     Partition    = commandPartition;
     if (parameters != null)
     {
         Parameters = parameters;
     }
 }
 internal static SpannerTransaction FromTransactionId(SpannerConnection connection, TransactionId transactionId)
 {
     return(new SpannerTransaction(
                connection, TransactionMode.ReadOnly, new Session {
         Name = transactionId.Session
     },
                new V1.Transaction {
         Id = ByteString.FromBase64(transactionId.Id)
     }, transactionId.TimestampBound)
     {
         Shared = true,
         DisposeBehavior = DisposeBehavior.Detach  //this transaction is coming from another process potentially, so we don't auto close it.
     });
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of <see cref="SpannerCommand"/>.
 /// </summary>
 /// <param name="connection">The <see cref="SpannerConnection"/> that is
 /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
 /// <param name="transaction">The <see cref="SpannerTransaction"/>
 /// used when creating the <see cref="CommandPartition"/>.
 /// </param>
 /// <param name="commandPartition">
 /// The partition which this command is restricted to.
 /// See <see cref="SpannerConnection.BeginReadOnlyTransaction(TransactionId)"/>
 /// </param>
 public SpannerCommand(
     SpannerConnection connection,
     SpannerTransaction transaction,
     CommandPartition commandPartition)
     : this(connection, transaction, null, commandPartition)
 {
     GaxPreconditions.CheckNotNull(connection, nameof(connection));
     GaxPreconditions.CheckNotNull(transaction, nameof(transaction));
     GaxPreconditions.CheckNotNull(commandPartition, nameof(commandPartition));
     SpannerCommandTextBuilder = commandPartition.Request.IsQuery
         ? SpannerCommandTextBuilder.FromCommandText(commandPartition.Request.ExecuteSqlRequest.Sql)
         : SpannerCommandTextBuilder.CreateReadTextBuilder(
         commandPartition.Request.ReadRequest.Table,
         ReadOptions.FromColumns(commandPartition.Request.ReadRequest.Columns));
 }
        internal SpannerTransaction(
            SpannerConnection connection,
            TransactionMode mode,
            Session session,
            Transaction transaction,
            TimestampBound timestampBound)
        {
            GaxPreconditions.CheckNotNull(connection, nameof(connection));
            GaxPreconditions.CheckNotNull(session, nameof(session));
            GaxPreconditions.CheckNotNull(transaction, nameof(transaction));

            Logger.LogPerformanceCounter(
                "Transactions.ActiveCount",
                () => Interlocked.Increment(ref s_transactionCount));

            Session         = session;
            TimestampBound  = timestampBound;
            WireTransaction = transaction;
            _connection     = connection;
            Mode            = mode;
        }
Exemplo n.º 9
0
 internal VolatileResourceManager(SpannerConnection spannerConnection, TimestampBound timestampBound, TransactionId transactionId)
 {
     _spannerConnection = spannerConnection;
     _timestampBound    = timestampBound;
     _transactionId     = transactionId;
 }
Exemplo n.º 10
0
 public VolatileResourceManager(SpannerConnection spannerConnection, TimestampBound timestampBound)
 {
     _spannerConnection = spannerConnection;
     _timestampBound    = timestampBound;
 }
 internal EphemeralTransaction(SpannerConnection connection, TransactionOptions transactionOptions)
 {
     _connection         = GaxPreconditions.CheckNotNull(connection, nameof(connection));
     _transactionOptions = transactionOptions;
 }
Exemplo n.º 12
0
 internal EphemeralTransaction(SpannerConnection connection, TransactionOptions transactionOptions, Priority commitPriority)
 {
     _connection         = GaxPreconditions.CheckNotNull(connection, nameof(connection));
     _transactionOptions = transactionOptions;
     _commitPriority     = commitPriority;
 }
 internal SpannerBatchCommand(SpannerConnection connection)
 {
     Connection = GaxPreconditions.CheckNotNull(connection, nameof(connection));
 }
Exemplo n.º 14
0
 public EphemeralTransaction(SpannerConnection connection)
 {
     GaxPreconditions.CheckNotNull(connection, nameof(connection));
     _connection = connection;
 }
 public PartitionedUpdateTransaction(SpannerConnection connection, Session session, Transaction wireTransaction)
 {
     _connection      = connection;
     _session         = session;
     _wireTransaction = wireTransaction;
 }
Exemplo n.º 16
0
 public EphemeralTransaction(SpannerConnection connection, Logger logger)
 {
     GaxPreconditions.CheckNotNull(connection, nameof(connection));
     _connection = connection;
     Logger      = logger ?? Logger.DefaultLogger;
 }