Class: Google::Cloud::Spanner::V1::TransactionOptions

Inherits:
Object
  • Object
show all
Extended by:
Protobuf::MessageExts::ClassMethods
Includes:
Protobuf::MessageExts
Defined in:
proto_docs/google/spanner/v1/transaction.rb

Overview

Options to use for transactions.

Defined Under Namespace

Modules: IsolationLevel Classes: PartitionedDml, ReadOnly, ReadWrite

Instance Attribute Summary collapse

Instance Attribute Details

#exclude_txn_from_change_streams::Boolean

Returns When exclude_txn_from_change_streams is set to true, it prevents read or write transactions from being tracked in change streams.

  • If the DDL option allow_txn_exclusion is set to true, then the updates made within this transaction aren't recorded in the change stream.

  • If you don't set the DDL option allow_txn_exclusion or if it's set to false, then the updates made within this transaction are recorded in the change stream.

When exclude_txn_from_change_streams is set to false or not set, modifications from this transaction are recorded in all change streams that are tracking columns modified by these transactions.

The exclude_txn_from_change_streams option can only be specified for read-write or partitioned DML transactions, otherwise the API returns an INVALID_ARGUMENT error.

Returns:

  • (::Boolean)

    When exclude_txn_from_change_streams is set to true, it prevents read or write transactions from being tracked in change streams.

    • If the DDL option allow_txn_exclusion is set to true, then the updates made within this transaction aren't recorded in the change stream.

    • If you don't set the DDL option allow_txn_exclusion or if it's set to false, then the updates made within this transaction are recorded in the change stream.

    When exclude_txn_from_change_streams is set to false or not set, modifications from this transaction are recorded in all change streams that are tracking columns modified by these transactions.

    The exclude_txn_from_change_streams option can only be specified for read-write or partitioned DML transactions, otherwise the API returns an INVALID_ARGUMENT error.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'proto_docs/google/spanner/v1/transaction.rb', line 75

class TransactionOptions
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Message type to initiate a read-write transaction. Currently this
  # transaction type has no options.
  # @!attribute [rw] read_lock_mode
  #   @return [::Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode]
  #     Read lock mode for the transaction.
  # @!attribute [rw] multiplexed_session_previous_transaction_id
  #   @return [::String]
  #     Optional. Clients should pass the transaction ID of the previous
  #     transaction attempt that was aborted if this transaction is being
  #     executed on a multiplexed session.
  class ReadWrite
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods

    # `ReadLockMode` is used to set the read lock mode for read-write
    # transactions.
    module ReadLockMode
      # Default value.
      #
      # * If isolation level is
      #   {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::REPEATABLE_READ REPEATABLE_READ},
      #   then it is an error to specify `read_lock_mode`. Locking semantics
      #   default to `OPTIMISTIC`. No validation checks are done for reads,
      #   except to validate that the data that was served at the snapshot time
      #   is unchanged at commit time in the following cases:
      #     1. reads done as part of queries that use `SELECT FOR UPDATE`
      #     2. reads done as part of statements with a `LOCK_SCANNED_RANGES`
      #        hint
      #     3. reads done as part of DML statements
      # * At all other isolation levels, if `read_lock_mode` is the default
      #   value, then pessimistic read locks are used.
      READ_LOCK_MODE_UNSPECIFIED = 0

      # Pessimistic lock mode.
      #
      # Read locks are acquired immediately on read.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      PESSIMISTIC = 1

      # Optimistic lock mode.
      #
      # Locks for reads within the transaction are not acquired on read.
      # Instead the locks are acquired on a commit to validate that
      # read/queried data has not changed since the transaction started.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      OPTIMISTIC = 2
    end
  end

  # Message type to initiate a Partitioned DML transaction.
  class PartitionedDml
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # Message type to initiate a read-only transaction.
  # @!attribute [rw] strong
  #   @return [::Boolean]
  #     Read at a timestamp where all previously committed transactions
  #     are visible.
  #
  #     Note: The following fields are mutually exclusive: `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] min_read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at a timestamp >= `min_read_timestamp`.
  #
  #     This is useful for requesting fresher data than some previous
  #     read, or data that is fresh enough to observe the effects of some
  #     previously committed transaction whose timestamp is known.
  #
  #     Note that this option can only be used in single-use transactions.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `min_read_timestamp`, `strong`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] max_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Read data at a timestamp >= `NOW - max_staleness`
  #     seconds. Guarantees that all writes that have committed more
  #     than the specified number of seconds ago are visible. Because
  #     Cloud Spanner chooses the exact timestamp, this mode works even if
  #     the client's local clock is substantially skewed from Cloud Spanner
  #     commit timestamps.
  #
  #     Useful for reading the freshest data available at a nearby
  #     replica, while bounding the possible staleness if the local
  #     replica has fallen behind.
  #
  #     Note that this option can only be used in single-use
  #     transactions.
  #
  #     Note: The following fields are mutually exclusive: `max_staleness`, `strong`, `min_read_timestamp`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at the given timestamp. Unlike other modes,
  #     reads at a specific timestamp are repeatable; the same read at
  #     the same timestamp always returns the same data. If the
  #     timestamp is in the future, the read is blocked until the
  #     specified timestamp, modulo the read's deadline.
  #
  #     Useful for large scale consistent reads such as mapreduces, or
  #     for coordinating many reads against a consistent snapshot of the
  #     data.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `read_timestamp`, `strong`, `min_read_timestamp`, `max_staleness`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] exact_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Executes all reads at a timestamp that is `exact_staleness`
  #     old. The timestamp is chosen soon after the read is started.
  #
  #     Guarantees that all writes that have committed more than the
  #     specified number of seconds ago are visible. Because Cloud Spanner
  #     chooses the exact timestamp, this mode works even if the client's
  #     local clock is substantially skewed from Cloud Spanner commit
  #     timestamps.
  #
  #     Useful for reading at nearby replicas without the distributed
  #     timestamp negotiation overhead of `max_staleness`.
  #
  #     Note: The following fields are mutually exclusive: `exact_staleness`, `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] return_read_timestamp
  #   @return [::Boolean]
  #     If true, the Cloud Spanner-selected read timestamp is included in
  #     the {::Google::Cloud::Spanner::V1::Transaction Transaction} message that describes
  #     the transaction.
  class ReadOnly
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # `IsolationLevel` is used when setting `isolation_level` for a transaction.
  module IsolationLevel
    # Default value.
    #
    # If the value is not specified, the `SERIALIZABLE` isolation level is
    # used.
    ISOLATION_LEVEL_UNSPECIFIED = 0

    # All transactions appear as if they executed in a serial order, even if
    # some of the reads, writes, and other operations of distinct transactions
    # actually occurred in parallel. Spanner assigns commit timestamps that
    # reflect the order of committed transactions to implement this property.
    # Spanner offers a stronger guarantee than serializability called external
    # consistency. For more information, see
    # [TrueTime and external
    # consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
    SERIALIZABLE = 1

    # All reads performed during the transaction observe a consistent snapshot
    # of the database, and the transaction is only successfully committed in
    # the absence of conflicts between its updates and any concurrent updates
    # that have occurred since that snapshot. Consequently, in contrast to
    # `SERIALIZABLE` transactions, only write-write conflicts are detected in
    # snapshot transactions.
    #
    # This isolation level does not support Read-only and Partitioned DML
    # transactions.
    #
    # When `REPEATABLE_READ` is specified on a read-write transaction, the
    # locking semantics default to `OPTIMISTIC`.
    REPEATABLE_READ = 2
  end
end

#isolation_level::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel

Returns Isolation level for the transaction.

Returns:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'proto_docs/google/spanner/v1/transaction.rb', line 75

class TransactionOptions
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Message type to initiate a read-write transaction. Currently this
  # transaction type has no options.
  # @!attribute [rw] read_lock_mode
  #   @return [::Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode]
  #     Read lock mode for the transaction.
  # @!attribute [rw] multiplexed_session_previous_transaction_id
  #   @return [::String]
  #     Optional. Clients should pass the transaction ID of the previous
  #     transaction attempt that was aborted if this transaction is being
  #     executed on a multiplexed session.
  class ReadWrite
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods

    # `ReadLockMode` is used to set the read lock mode for read-write
    # transactions.
    module ReadLockMode
      # Default value.
      #
      # * If isolation level is
      #   {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::REPEATABLE_READ REPEATABLE_READ},
      #   then it is an error to specify `read_lock_mode`. Locking semantics
      #   default to `OPTIMISTIC`. No validation checks are done for reads,
      #   except to validate that the data that was served at the snapshot time
      #   is unchanged at commit time in the following cases:
      #     1. reads done as part of queries that use `SELECT FOR UPDATE`
      #     2. reads done as part of statements with a `LOCK_SCANNED_RANGES`
      #        hint
      #     3. reads done as part of DML statements
      # * At all other isolation levels, if `read_lock_mode` is the default
      #   value, then pessimistic read locks are used.
      READ_LOCK_MODE_UNSPECIFIED = 0

      # Pessimistic lock mode.
      #
      # Read locks are acquired immediately on read.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      PESSIMISTIC = 1

      # Optimistic lock mode.
      #
      # Locks for reads within the transaction are not acquired on read.
      # Instead the locks are acquired on a commit to validate that
      # read/queried data has not changed since the transaction started.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      OPTIMISTIC = 2
    end
  end

  # Message type to initiate a Partitioned DML transaction.
  class PartitionedDml
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # Message type to initiate a read-only transaction.
  # @!attribute [rw] strong
  #   @return [::Boolean]
  #     Read at a timestamp where all previously committed transactions
  #     are visible.
  #
  #     Note: The following fields are mutually exclusive: `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] min_read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at a timestamp >= `min_read_timestamp`.
  #
  #     This is useful for requesting fresher data than some previous
  #     read, or data that is fresh enough to observe the effects of some
  #     previously committed transaction whose timestamp is known.
  #
  #     Note that this option can only be used in single-use transactions.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `min_read_timestamp`, `strong`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] max_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Read data at a timestamp >= `NOW - max_staleness`
  #     seconds. Guarantees that all writes that have committed more
  #     than the specified number of seconds ago are visible. Because
  #     Cloud Spanner chooses the exact timestamp, this mode works even if
  #     the client's local clock is substantially skewed from Cloud Spanner
  #     commit timestamps.
  #
  #     Useful for reading the freshest data available at a nearby
  #     replica, while bounding the possible staleness if the local
  #     replica has fallen behind.
  #
  #     Note that this option can only be used in single-use
  #     transactions.
  #
  #     Note: The following fields are mutually exclusive: `max_staleness`, `strong`, `min_read_timestamp`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at the given timestamp. Unlike other modes,
  #     reads at a specific timestamp are repeatable; the same read at
  #     the same timestamp always returns the same data. If the
  #     timestamp is in the future, the read is blocked until the
  #     specified timestamp, modulo the read's deadline.
  #
  #     Useful for large scale consistent reads such as mapreduces, or
  #     for coordinating many reads against a consistent snapshot of the
  #     data.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `read_timestamp`, `strong`, `min_read_timestamp`, `max_staleness`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] exact_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Executes all reads at a timestamp that is `exact_staleness`
  #     old. The timestamp is chosen soon after the read is started.
  #
  #     Guarantees that all writes that have committed more than the
  #     specified number of seconds ago are visible. Because Cloud Spanner
  #     chooses the exact timestamp, this mode works even if the client's
  #     local clock is substantially skewed from Cloud Spanner commit
  #     timestamps.
  #
  #     Useful for reading at nearby replicas without the distributed
  #     timestamp negotiation overhead of `max_staleness`.
  #
  #     Note: The following fields are mutually exclusive: `exact_staleness`, `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] return_read_timestamp
  #   @return [::Boolean]
  #     If true, the Cloud Spanner-selected read timestamp is included in
  #     the {::Google::Cloud::Spanner::V1::Transaction Transaction} message that describes
  #     the transaction.
  class ReadOnly
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # `IsolationLevel` is used when setting `isolation_level` for a transaction.
  module IsolationLevel
    # Default value.
    #
    # If the value is not specified, the `SERIALIZABLE` isolation level is
    # used.
    ISOLATION_LEVEL_UNSPECIFIED = 0

    # All transactions appear as if they executed in a serial order, even if
    # some of the reads, writes, and other operations of distinct transactions
    # actually occurred in parallel. Spanner assigns commit timestamps that
    # reflect the order of committed transactions to implement this property.
    # Spanner offers a stronger guarantee than serializability called external
    # consistency. For more information, see
    # [TrueTime and external
    # consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
    SERIALIZABLE = 1

    # All reads performed during the transaction observe a consistent snapshot
    # of the database, and the transaction is only successfully committed in
    # the absence of conflicts between its updates and any concurrent updates
    # that have occurred since that snapshot. Consequently, in contrast to
    # `SERIALIZABLE` transactions, only write-write conflicts are detected in
    # snapshot transactions.
    #
    # This isolation level does not support Read-only and Partitioned DML
    # transactions.
    #
    # When `REPEATABLE_READ` is specified on a read-write transaction, the
    # locking semantics default to `OPTIMISTIC`.
    REPEATABLE_READ = 2
  end
end

#partitioned_dml::Google::Cloud::Spanner::V1::TransactionOptions::PartitionedDml

Returns Partitioned DML transaction.

Authorization to begin a Partitioned DML transaction requires spanner.databases.beginPartitionedDmlTransaction permission on the session resource.

Note: The following fields are mutually exclusive: partitioned_dml, read_write, read_only. If a field in that set is populated, all other fields in the set will automatically be cleared.

Returns:

  • (::Google::Cloud::Spanner::V1::TransactionOptions::PartitionedDml)

    Partitioned DML transaction.

    Authorization to begin a Partitioned DML transaction requires spanner.databases.beginPartitionedDmlTransaction permission on the session resource.

    Note: The following fields are mutually exclusive: partitioned_dml, read_write, read_only. If a field in that set is populated, all other fields in the set will automatically be cleared.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'proto_docs/google/spanner/v1/transaction.rb', line 75

class TransactionOptions
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Message type to initiate a read-write transaction. Currently this
  # transaction type has no options.
  # @!attribute [rw] read_lock_mode
  #   @return [::Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode]
  #     Read lock mode for the transaction.
  # @!attribute [rw] multiplexed_session_previous_transaction_id
  #   @return [::String]
  #     Optional. Clients should pass the transaction ID of the previous
  #     transaction attempt that was aborted if this transaction is being
  #     executed on a multiplexed session.
  class ReadWrite
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods

    # `ReadLockMode` is used to set the read lock mode for read-write
    # transactions.
    module ReadLockMode
      # Default value.
      #
      # * If isolation level is
      #   {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::REPEATABLE_READ REPEATABLE_READ},
      #   then it is an error to specify `read_lock_mode`. Locking semantics
      #   default to `OPTIMISTIC`. No validation checks are done for reads,
      #   except to validate that the data that was served at the snapshot time
      #   is unchanged at commit time in the following cases:
      #     1. reads done as part of queries that use `SELECT FOR UPDATE`
      #     2. reads done as part of statements with a `LOCK_SCANNED_RANGES`
      #        hint
      #     3. reads done as part of DML statements
      # * At all other isolation levels, if `read_lock_mode` is the default
      #   value, then pessimistic read locks are used.
      READ_LOCK_MODE_UNSPECIFIED = 0

      # Pessimistic lock mode.
      #
      # Read locks are acquired immediately on read.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      PESSIMISTIC = 1

      # Optimistic lock mode.
      #
      # Locks for reads within the transaction are not acquired on read.
      # Instead the locks are acquired on a commit to validate that
      # read/queried data has not changed since the transaction started.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      OPTIMISTIC = 2
    end
  end

  # Message type to initiate a Partitioned DML transaction.
  class PartitionedDml
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # Message type to initiate a read-only transaction.
  # @!attribute [rw] strong
  #   @return [::Boolean]
  #     Read at a timestamp where all previously committed transactions
  #     are visible.
  #
  #     Note: The following fields are mutually exclusive: `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] min_read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at a timestamp >= `min_read_timestamp`.
  #
  #     This is useful for requesting fresher data than some previous
  #     read, or data that is fresh enough to observe the effects of some
  #     previously committed transaction whose timestamp is known.
  #
  #     Note that this option can only be used in single-use transactions.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `min_read_timestamp`, `strong`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] max_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Read data at a timestamp >= `NOW - max_staleness`
  #     seconds. Guarantees that all writes that have committed more
  #     than the specified number of seconds ago are visible. Because
  #     Cloud Spanner chooses the exact timestamp, this mode works even if
  #     the client's local clock is substantially skewed from Cloud Spanner
  #     commit timestamps.
  #
  #     Useful for reading the freshest data available at a nearby
  #     replica, while bounding the possible staleness if the local
  #     replica has fallen behind.
  #
  #     Note that this option can only be used in single-use
  #     transactions.
  #
  #     Note: The following fields are mutually exclusive: `max_staleness`, `strong`, `min_read_timestamp`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at the given timestamp. Unlike other modes,
  #     reads at a specific timestamp are repeatable; the same read at
  #     the same timestamp always returns the same data. If the
  #     timestamp is in the future, the read is blocked until the
  #     specified timestamp, modulo the read's deadline.
  #
  #     Useful for large scale consistent reads such as mapreduces, or
  #     for coordinating many reads against a consistent snapshot of the
  #     data.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `read_timestamp`, `strong`, `min_read_timestamp`, `max_staleness`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] exact_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Executes all reads at a timestamp that is `exact_staleness`
  #     old. The timestamp is chosen soon after the read is started.
  #
  #     Guarantees that all writes that have committed more than the
  #     specified number of seconds ago are visible. Because Cloud Spanner
  #     chooses the exact timestamp, this mode works even if the client's
  #     local clock is substantially skewed from Cloud Spanner commit
  #     timestamps.
  #
  #     Useful for reading at nearby replicas without the distributed
  #     timestamp negotiation overhead of `max_staleness`.
  #
  #     Note: The following fields are mutually exclusive: `exact_staleness`, `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] return_read_timestamp
  #   @return [::Boolean]
  #     If true, the Cloud Spanner-selected read timestamp is included in
  #     the {::Google::Cloud::Spanner::V1::Transaction Transaction} message that describes
  #     the transaction.
  class ReadOnly
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # `IsolationLevel` is used when setting `isolation_level` for a transaction.
  module IsolationLevel
    # Default value.
    #
    # If the value is not specified, the `SERIALIZABLE` isolation level is
    # used.
    ISOLATION_LEVEL_UNSPECIFIED = 0

    # All transactions appear as if they executed in a serial order, even if
    # some of the reads, writes, and other operations of distinct transactions
    # actually occurred in parallel. Spanner assigns commit timestamps that
    # reflect the order of committed transactions to implement this property.
    # Spanner offers a stronger guarantee than serializability called external
    # consistency. For more information, see
    # [TrueTime and external
    # consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
    SERIALIZABLE = 1

    # All reads performed during the transaction observe a consistent snapshot
    # of the database, and the transaction is only successfully committed in
    # the absence of conflicts between its updates and any concurrent updates
    # that have occurred since that snapshot. Consequently, in contrast to
    # `SERIALIZABLE` transactions, only write-write conflicts are detected in
    # snapshot transactions.
    #
    # This isolation level does not support Read-only and Partitioned DML
    # transactions.
    #
    # When `REPEATABLE_READ` is specified on a read-write transaction, the
    # locking semantics default to `OPTIMISTIC`.
    REPEATABLE_READ = 2
  end
end

#read_only::Google::Cloud::Spanner::V1::TransactionOptions::ReadOnly

Returns Transaction does not write.

Authorization to begin a read-only transaction requires spanner.databases.beginReadOnlyTransaction permission on the session resource.

Note: The following fields are mutually exclusive: read_only, read_write, partitioned_dml. If a field in that set is populated, all other fields in the set will automatically be cleared.

Returns:

  • (::Google::Cloud::Spanner::V1::TransactionOptions::ReadOnly)

    Transaction does not write.

    Authorization to begin a read-only transaction requires spanner.databases.beginReadOnlyTransaction permission on the session resource.

    Note: The following fields are mutually exclusive: read_only, read_write, partitioned_dml. If a field in that set is populated, all other fields in the set will automatically be cleared.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'proto_docs/google/spanner/v1/transaction.rb', line 75

class TransactionOptions
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Message type to initiate a read-write transaction. Currently this
  # transaction type has no options.
  # @!attribute [rw] read_lock_mode
  #   @return [::Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode]
  #     Read lock mode for the transaction.
  # @!attribute [rw] multiplexed_session_previous_transaction_id
  #   @return [::String]
  #     Optional. Clients should pass the transaction ID of the previous
  #     transaction attempt that was aborted if this transaction is being
  #     executed on a multiplexed session.
  class ReadWrite
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods

    # `ReadLockMode` is used to set the read lock mode for read-write
    # transactions.
    module ReadLockMode
      # Default value.
      #
      # * If isolation level is
      #   {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::REPEATABLE_READ REPEATABLE_READ},
      #   then it is an error to specify `read_lock_mode`. Locking semantics
      #   default to `OPTIMISTIC`. No validation checks are done for reads,
      #   except to validate that the data that was served at the snapshot time
      #   is unchanged at commit time in the following cases:
      #     1. reads done as part of queries that use `SELECT FOR UPDATE`
      #     2. reads done as part of statements with a `LOCK_SCANNED_RANGES`
      #        hint
      #     3. reads done as part of DML statements
      # * At all other isolation levels, if `read_lock_mode` is the default
      #   value, then pessimistic read locks are used.
      READ_LOCK_MODE_UNSPECIFIED = 0

      # Pessimistic lock mode.
      #
      # Read locks are acquired immediately on read.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      PESSIMISTIC = 1

      # Optimistic lock mode.
      #
      # Locks for reads within the transaction are not acquired on read.
      # Instead the locks are acquired on a commit to validate that
      # read/queried data has not changed since the transaction started.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      OPTIMISTIC = 2
    end
  end

  # Message type to initiate a Partitioned DML transaction.
  class PartitionedDml
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # Message type to initiate a read-only transaction.
  # @!attribute [rw] strong
  #   @return [::Boolean]
  #     Read at a timestamp where all previously committed transactions
  #     are visible.
  #
  #     Note: The following fields are mutually exclusive: `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] min_read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at a timestamp >= `min_read_timestamp`.
  #
  #     This is useful for requesting fresher data than some previous
  #     read, or data that is fresh enough to observe the effects of some
  #     previously committed transaction whose timestamp is known.
  #
  #     Note that this option can only be used in single-use transactions.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `min_read_timestamp`, `strong`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] max_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Read data at a timestamp >= `NOW - max_staleness`
  #     seconds. Guarantees that all writes that have committed more
  #     than the specified number of seconds ago are visible. Because
  #     Cloud Spanner chooses the exact timestamp, this mode works even if
  #     the client's local clock is substantially skewed from Cloud Spanner
  #     commit timestamps.
  #
  #     Useful for reading the freshest data available at a nearby
  #     replica, while bounding the possible staleness if the local
  #     replica has fallen behind.
  #
  #     Note that this option can only be used in single-use
  #     transactions.
  #
  #     Note: The following fields are mutually exclusive: `max_staleness`, `strong`, `min_read_timestamp`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at the given timestamp. Unlike other modes,
  #     reads at a specific timestamp are repeatable; the same read at
  #     the same timestamp always returns the same data. If the
  #     timestamp is in the future, the read is blocked until the
  #     specified timestamp, modulo the read's deadline.
  #
  #     Useful for large scale consistent reads such as mapreduces, or
  #     for coordinating many reads against a consistent snapshot of the
  #     data.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `read_timestamp`, `strong`, `min_read_timestamp`, `max_staleness`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] exact_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Executes all reads at a timestamp that is `exact_staleness`
  #     old. The timestamp is chosen soon after the read is started.
  #
  #     Guarantees that all writes that have committed more than the
  #     specified number of seconds ago are visible. Because Cloud Spanner
  #     chooses the exact timestamp, this mode works even if the client's
  #     local clock is substantially skewed from Cloud Spanner commit
  #     timestamps.
  #
  #     Useful for reading at nearby replicas without the distributed
  #     timestamp negotiation overhead of `max_staleness`.
  #
  #     Note: The following fields are mutually exclusive: `exact_staleness`, `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] return_read_timestamp
  #   @return [::Boolean]
  #     If true, the Cloud Spanner-selected read timestamp is included in
  #     the {::Google::Cloud::Spanner::V1::Transaction Transaction} message that describes
  #     the transaction.
  class ReadOnly
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # `IsolationLevel` is used when setting `isolation_level` for a transaction.
  module IsolationLevel
    # Default value.
    #
    # If the value is not specified, the `SERIALIZABLE` isolation level is
    # used.
    ISOLATION_LEVEL_UNSPECIFIED = 0

    # All transactions appear as if they executed in a serial order, even if
    # some of the reads, writes, and other operations of distinct transactions
    # actually occurred in parallel. Spanner assigns commit timestamps that
    # reflect the order of committed transactions to implement this property.
    # Spanner offers a stronger guarantee than serializability called external
    # consistency. For more information, see
    # [TrueTime and external
    # consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
    SERIALIZABLE = 1

    # All reads performed during the transaction observe a consistent snapshot
    # of the database, and the transaction is only successfully committed in
    # the absence of conflicts between its updates and any concurrent updates
    # that have occurred since that snapshot. Consequently, in contrast to
    # `SERIALIZABLE` transactions, only write-write conflicts are detected in
    # snapshot transactions.
    #
    # This isolation level does not support Read-only and Partitioned DML
    # transactions.
    #
    # When `REPEATABLE_READ` is specified on a read-write transaction, the
    # locking semantics default to `OPTIMISTIC`.
    REPEATABLE_READ = 2
  end
end

#read_write::Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite

Returns Transaction may write.

Authorization to begin a read-write transaction requires spanner.databases.beginOrRollbackReadWriteTransaction permission on the session resource.

Note: The following fields are mutually exclusive: read_write, partitioned_dml, read_only. If a field in that set is populated, all other fields in the set will automatically be cleared.

Returns:

  • (::Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite)

    Transaction may write.

    Authorization to begin a read-write transaction requires spanner.databases.beginOrRollbackReadWriteTransaction permission on the session resource.

    Note: The following fields are mutually exclusive: read_write, partitioned_dml, read_only. If a field in that set is populated, all other fields in the set will automatically be cleared.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'proto_docs/google/spanner/v1/transaction.rb', line 75

class TransactionOptions
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Message type to initiate a read-write transaction. Currently this
  # transaction type has no options.
  # @!attribute [rw] read_lock_mode
  #   @return [::Google::Cloud::Spanner::V1::TransactionOptions::ReadWrite::ReadLockMode]
  #     Read lock mode for the transaction.
  # @!attribute [rw] multiplexed_session_previous_transaction_id
  #   @return [::String]
  #     Optional. Clients should pass the transaction ID of the previous
  #     transaction attempt that was aborted if this transaction is being
  #     executed on a multiplexed session.
  class ReadWrite
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods

    # `ReadLockMode` is used to set the read lock mode for read-write
    # transactions.
    module ReadLockMode
      # Default value.
      #
      # * If isolation level is
      #   {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::REPEATABLE_READ REPEATABLE_READ},
      #   then it is an error to specify `read_lock_mode`. Locking semantics
      #   default to `OPTIMISTIC`. No validation checks are done for reads,
      #   except to validate that the data that was served at the snapshot time
      #   is unchanged at commit time in the following cases:
      #     1. reads done as part of queries that use `SELECT FOR UPDATE`
      #     2. reads done as part of statements with a `LOCK_SCANNED_RANGES`
      #        hint
      #     3. reads done as part of DML statements
      # * At all other isolation levels, if `read_lock_mode` is the default
      #   value, then pessimistic read locks are used.
      READ_LOCK_MODE_UNSPECIFIED = 0

      # Pessimistic lock mode.
      #
      # Read locks are acquired immediately on read.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      PESSIMISTIC = 1

      # Optimistic lock mode.
      #
      # Locks for reads within the transaction are not acquired on read.
      # Instead the locks are acquired on a commit to validate that
      # read/queried data has not changed since the transaction started.
      # Semantics described only applies to
      # {::Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel::SERIALIZABLE SERIALIZABLE}
      # isolation.
      OPTIMISTIC = 2
    end
  end

  # Message type to initiate a Partitioned DML transaction.
  class PartitionedDml
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # Message type to initiate a read-only transaction.
  # @!attribute [rw] strong
  #   @return [::Boolean]
  #     Read at a timestamp where all previously committed transactions
  #     are visible.
  #
  #     Note: The following fields are mutually exclusive: `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] min_read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at a timestamp >= `min_read_timestamp`.
  #
  #     This is useful for requesting fresher data than some previous
  #     read, or data that is fresh enough to observe the effects of some
  #     previously committed transaction whose timestamp is known.
  #
  #     Note that this option can only be used in single-use transactions.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `min_read_timestamp`, `strong`, `max_staleness`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] max_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Read data at a timestamp >= `NOW - max_staleness`
  #     seconds. Guarantees that all writes that have committed more
  #     than the specified number of seconds ago are visible. Because
  #     Cloud Spanner chooses the exact timestamp, this mode works even if
  #     the client's local clock is substantially skewed from Cloud Spanner
  #     commit timestamps.
  #
  #     Useful for reading the freshest data available at a nearby
  #     replica, while bounding the possible staleness if the local
  #     replica has fallen behind.
  #
  #     Note that this option can only be used in single-use
  #     transactions.
  #
  #     Note: The following fields are mutually exclusive: `max_staleness`, `strong`, `min_read_timestamp`, `read_timestamp`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] read_timestamp
  #   @return [::Google::Protobuf::Timestamp]
  #     Executes all reads at the given timestamp. Unlike other modes,
  #     reads at a specific timestamp are repeatable; the same read at
  #     the same timestamp always returns the same data. If the
  #     timestamp is in the future, the read is blocked until the
  #     specified timestamp, modulo the read's deadline.
  #
  #     Useful for large scale consistent reads such as mapreduces, or
  #     for coordinating many reads against a consistent snapshot of the
  #     data.
  #
  #     A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
  #     Example: `"2014-10-02T15:01:23.045123456Z"`.
  #
  #     Note: The following fields are mutually exclusive: `read_timestamp`, `strong`, `min_read_timestamp`, `max_staleness`, `exact_staleness`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] exact_staleness
  #   @return [::Google::Protobuf::Duration]
  #     Executes all reads at a timestamp that is `exact_staleness`
  #     old. The timestamp is chosen soon after the read is started.
  #
  #     Guarantees that all writes that have committed more than the
  #     specified number of seconds ago are visible. Because Cloud Spanner
  #     chooses the exact timestamp, this mode works even if the client's
  #     local clock is substantially skewed from Cloud Spanner commit
  #     timestamps.
  #
  #     Useful for reading at nearby replicas without the distributed
  #     timestamp negotiation overhead of `max_staleness`.
  #
  #     Note: The following fields are mutually exclusive: `exact_staleness`, `strong`, `min_read_timestamp`, `max_staleness`, `read_timestamp`. If a field in that set is populated, all other fields in the set will automatically be cleared.
  # @!attribute [rw] return_read_timestamp
  #   @return [::Boolean]
  #     If true, the Cloud Spanner-selected read timestamp is included in
  #     the {::Google::Cloud::Spanner::V1::Transaction Transaction} message that describes
  #     the transaction.
  class ReadOnly
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods
  end

  # `IsolationLevel` is used when setting `isolation_level` for a transaction.
  module IsolationLevel
    # Default value.
    #
    # If the value is not specified, the `SERIALIZABLE` isolation level is
    # used.
    ISOLATION_LEVEL_UNSPECIFIED = 0

    # All transactions appear as if they executed in a serial order, even if
    # some of the reads, writes, and other operations of distinct transactions
    # actually occurred in parallel. Spanner assigns commit timestamps that
    # reflect the order of committed transactions to implement this property.
    # Spanner offers a stronger guarantee than serializability called external
    # consistency. For more information, see
    # [TrueTime and external
    # consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
    SERIALIZABLE = 1

    # All reads performed during the transaction observe a consistent snapshot
    # of the database, and the transaction is only successfully committed in
    # the absence of conflicts between its updates and any concurrent updates
    # that have occurred since that snapshot. Consequently, in contrast to
    # `SERIALIZABLE` transactions, only write-write conflicts are detected in
    # snapshot transactions.
    #
    # This isolation level does not support Read-only and Partitioned DML
    # transactions.
    #
    # When `REPEATABLE_READ` is specified on a read-write transaction, the
    # locking semantics default to `OPTIMISTIC`.
    REPEATABLE_READ = 2
  end
end