Пример #1
0
        /// <summary>
        /// Creates an instance of <see cref="TransactionId"/> given its Base64 encoded string.
        /// </summary>
        /// <param name="base64String">The string provided by <see cref="TransactionId.ToBase64String"/>.</param>
        /// <returns>A new instance of <see cref="TransactionId"/>.</returns>
        public static TransactionId FromBase64String(string base64String)
        {
            var structValue = new Struct();

            structValue.MergeFrom(ByteString.FromBase64(base64String));
            string         connectionString = null, session = null, id = null;
            TimestampBound timestampBound = null;

            if (structValue.Fields.TryGetValue(nameof(ConnectionString), out Value connectionStringValue))
            {
                connectionString = connectionStringValue.StringValue;
            }
            if (structValue.Fields.TryGetValue(nameof(Session), out Value sessionStringValue))
            {
                session = sessionStringValue.StringValue;
            }
            if (structValue.Fields.TryGetValue(nameof(Id), out Value idValue))
            {
                id = idValue.StringValue;
            }
            if (structValue.Fields.TryGetValue(nameof(TimestampBound), out Value timestampBoundModeValue))
            {
                timestampBound = TimestampBound.FromBase64String(timestampBoundModeValue.StringValue);
            }
            return(new TransactionId(connectionString, session, id, timestampBound));
        }
Пример #2
0
 internal TransactionId(string connectionString, string session, string id, TimestampBound timestampBound)
 {
     ConnectionString = connectionString;
     Session          = session;
     TimestampBound   = timestampBound;
     Id = id;
 }
Пример #3
0
 internal VolatileResourceManager(SpannerConnection spannerConnection, TimestampBound timestampBound, TransactionId transactionId)
 {
     _spannerConnection = spannerConnection;
     _timestampBound    = timestampBound;
     _transaction       = new Lazy <Task <SpannerTransaction> >(CreateTransactionAsync, LazyThreadSafetyMode.ExecutionAndPublication);
     _transactionId     = transactionId;
 }
        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;
        }
Пример #5
0
 internal VolatileResourceManager(SpannerConnection spannerConnection, TimestampBound timestampBound, TransactionId transactionId)
 {
     _spannerConnection = spannerConnection;
     _timestampBound    = timestampBound;
     _transactionId     = transactionId;
 }
Пример #6
0
 public VolatileResourceManager(SpannerConnection spannerConnection, TimestampBound timestampBound)
 {
     _spannerConnection = spannerConnection;
     _timestampBound    = timestampBound;
 }