google-cloud-spanner 2.36.1 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/google/cloud/spanner/commit.rb +133 -0
- data/lib/google/cloud/spanner/transaction.rb +73 -0
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '076293b0ad0c908dfa858b6a370dd3ad88d99f26739c85f72292c41329991228'
|
|
4
|
+
data.tar.gz: 499e83b90c725a4c84058708e4af53e1db4839f312c263b2f41b8e27b233cce0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b4ffb38b9c48441e24490158a37932846f3befcd6633db3fde64c4ab036f472367bcf62817a0118d783ee981216a7ba5343dab51b1e0e2bb48332d796903817
|
|
7
|
+
data.tar.gz: b41377cf7cb39c851ba30dfd259413c78c62c1341eb539b73ef1376286d93bb010ffa85def0cc7b99522d01589b5cb2ea0290174f53c285f69cc4366140337bb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
### 2.37.0 (2026-10-28)
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* add send_message and ack_message to Commit ([#262](https://github.com/googleapis/ruby-spanner/issues/262))
|
|
8
|
+
* add send_message and ack_message to Transaction ([#263](https://github.com/googleapis/ruby-spanner/issues/263))
|
|
9
|
+
#### Documentation
|
|
10
|
+
|
|
11
|
+
* link to the published Ruby version support policy ([#272](https://github.com/googleapis/ruby-spanner/issues/272))
|
|
12
|
+
|
|
3
13
|
### 2.36.1 (2026-10-13)
|
|
4
14
|
|
|
5
15
|
#### Documentation
|
|
@@ -280,6 +280,124 @@ module Google
|
|
|
280
280
|
keys
|
|
281
281
|
end
|
|
282
282
|
|
|
283
|
+
##
|
|
284
|
+
# Sends a message to a queue.
|
|
285
|
+
#
|
|
286
|
+
# All changes are accumulated in memory until the block passed to
|
|
287
|
+
# {Client#commit} completes.
|
|
288
|
+
#
|
|
289
|
+
# @param [String] queue The name of the queue.
|
|
290
|
+
# @param [Object, Array<Object>] key A single key or array of composite key parts for the message.
|
|
291
|
+
# @param [String, IO, StringIO, Hash, Google::Protobuf::MessageExts] payload
|
|
292
|
+
# The message payload. It is converted the same way as column values
|
|
293
|
+
# (see {#upsert}), so its type must match the queue's payload column,
|
|
294
|
+
# such as a `String` for `STRING` or a `StringIO` for `BYTES`:
|
|
295
|
+
# * `String` - Sent as text.
|
|
296
|
+
# * `IO`, `StringIO`, `File` - Sent as bytes (Base64-encoded). Ruby has
|
|
297
|
+
# no bytes type, so wrap binary data in a `StringIO`.
|
|
298
|
+
# * `Hash` - Serialized to a JSON string.
|
|
299
|
+
# * `Google::Protobuf::MessageExts` - Serialized and Base64-encoded.
|
|
300
|
+
# @param [Time, nil] deliver_time The time at which Spanner begins
|
|
301
|
+
# trying to deliver the message. Optional. If not set, the message is
|
|
302
|
+
# delivered immediately. A time in the past is replaced with a time
|
|
303
|
+
# closer to the current time.
|
|
304
|
+
#
|
|
305
|
+
# @return [Object, Array<Object>] The key of the message.
|
|
306
|
+
#
|
|
307
|
+
# @raise [ArgumentError] If the payload type is unsupported.
|
|
308
|
+
#
|
|
309
|
+
# @example
|
|
310
|
+
# require "google/cloud/spanner"
|
|
311
|
+
#
|
|
312
|
+
# spanner = Google::Cloud::Spanner.new
|
|
313
|
+
#
|
|
314
|
+
# db = spanner.client "my-instance", "my-database"
|
|
315
|
+
#
|
|
316
|
+
# # OrderQueue has a STRING(MAX) payload column.
|
|
317
|
+
# db.commit do |c|
|
|
318
|
+
# c.send_message "OrderQueue", 101, "Order payload"
|
|
319
|
+
# end
|
|
320
|
+
#
|
|
321
|
+
# @example Send binary data to a queue with a BYTES payload column
|
|
322
|
+
# require "google/cloud/spanner"
|
|
323
|
+
#
|
|
324
|
+
# spanner = Google::Cloud::Spanner.new
|
|
325
|
+
#
|
|
326
|
+
# db = spanner.client "my-instance", "my-database"
|
|
327
|
+
#
|
|
328
|
+
# db.commit do |c|
|
|
329
|
+
# c.send_message "LabelQueue", 101, StringIO.new(File.binread("label.png"))
|
|
330
|
+
# end
|
|
331
|
+
#
|
|
332
|
+
# @example Deliver the message in five minutes
|
|
333
|
+
# require "google/cloud/spanner"
|
|
334
|
+
#
|
|
335
|
+
# spanner = Google::Cloud::Spanner.new
|
|
336
|
+
#
|
|
337
|
+
# db = spanner.client "my-instance", "my-database"
|
|
338
|
+
#
|
|
339
|
+
# db.commit do |c|
|
|
340
|
+
# c.send_message "OrderQueue", 101, "Order payload",
|
|
341
|
+
# deliver_time: Time.now + 300
|
|
342
|
+
# end
|
|
343
|
+
#
|
|
344
|
+
def send_message queue, key, payload, deliver_time: nil
|
|
345
|
+
send_mutation = V1::Mutation::Send.new(
|
|
346
|
+
queue: queue,
|
|
347
|
+
key: key_list_value(key),
|
|
348
|
+
payload: Convert.object_to_grpc_value(payload),
|
|
349
|
+
deliver_time: Convert.time_to_timestamp(deliver_time)
|
|
350
|
+
)
|
|
351
|
+
@mutations += [V1::Mutation.new(send: send_mutation)]
|
|
352
|
+
key
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
##
|
|
356
|
+
# Acknowledges a message in a queue, which removes it from the queue.
|
|
357
|
+
#
|
|
358
|
+
# All changes are accumulated in memory until the block passed to
|
|
359
|
+
# {Client#commit} completes.
|
|
360
|
+
#
|
|
361
|
+
# @param [String] queue The name of the queue.
|
|
362
|
+
# @param [Object, Array<Object>] key A single key or array of composite key parts to match.
|
|
363
|
+
# @param [Boolean] ignore_not_found If `true`, the ack succeeds even if
|
|
364
|
+
# the message doesn't exist. Optional. The default is `false`, which
|
|
365
|
+
# fails the commit with `NOT_FOUND` when the message doesn't exist.
|
|
366
|
+
#
|
|
367
|
+
# @return [Object, Array<Object>] The key of the message.
|
|
368
|
+
#
|
|
369
|
+
# @example
|
|
370
|
+
# require "google/cloud/spanner"
|
|
371
|
+
#
|
|
372
|
+
# spanner = Google::Cloud::Spanner.new
|
|
373
|
+
#
|
|
374
|
+
# db = spanner.client "my-instance", "my-database"
|
|
375
|
+
#
|
|
376
|
+
# db.commit do |c|
|
|
377
|
+
# c.ack_message "OrderQueue", 101
|
|
378
|
+
# end
|
|
379
|
+
#
|
|
380
|
+
# @example Ack a message whether or not it exists
|
|
381
|
+
# require "google/cloud/spanner"
|
|
382
|
+
#
|
|
383
|
+
# spanner = Google::Cloud::Spanner.new
|
|
384
|
+
#
|
|
385
|
+
# db = spanner.client "my-instance", "my-database"
|
|
386
|
+
#
|
|
387
|
+
# db.commit do |c|
|
|
388
|
+
# c.ack_message "OrderQueue", 101, ignore_not_found: true
|
|
389
|
+
# end
|
|
390
|
+
#
|
|
391
|
+
def ack_message queue, key, ignore_not_found: false
|
|
392
|
+
ack_mutation = V1::Mutation::Ack.new(
|
|
393
|
+
queue: queue,
|
|
394
|
+
key: key_list_value(key),
|
|
395
|
+
ignore_not_found: ignore_not_found
|
|
396
|
+
)
|
|
397
|
+
@mutations += [V1::Mutation.new(ack: ack_mutation)]
|
|
398
|
+
key
|
|
399
|
+
end
|
|
400
|
+
|
|
283
401
|
# Return the current mutations added to this `Spanner::Commit` object.
|
|
284
402
|
# @private
|
|
285
403
|
# @return [Array<Google::Cloud::Spanner::V1::Mutation>]
|
|
@@ -325,6 +443,21 @@ module Google
|
|
|
325
443
|
rows
|
|
326
444
|
end
|
|
327
445
|
|
|
446
|
+
##
|
|
447
|
+
# @private
|
|
448
|
+
# Generates a `ListValue` protobuf containing gRPC values for the given primary key.
|
|
449
|
+
#
|
|
450
|
+
# @param [Object, Array<Object>] key A scalar key, or an array of a composite key's parts.
|
|
451
|
+
# @return [Google::Protobuf::ListValue]
|
|
452
|
+
#
|
|
453
|
+
def key_list_value key
|
|
454
|
+
key = [key] unless key.is_a? Array
|
|
455
|
+
key_list = key.map do |k|
|
|
456
|
+
Convert.object_to_grpc_value k
|
|
457
|
+
end
|
|
458
|
+
Google::Protobuf::ListValue.new values: key_list
|
|
459
|
+
end
|
|
460
|
+
|
|
328
461
|
def key_set keys
|
|
329
462
|
return V1::KeySet.new all: true if keys.nil?
|
|
330
463
|
keys = [keys] unless keys.is_a? Array
|
|
@@ -1075,6 +1075,79 @@ module Google
|
|
|
1075
1075
|
@commit.delete table, keys
|
|
1076
1076
|
end
|
|
1077
1077
|
|
|
1078
|
+
##
|
|
1079
|
+
# Sends a message to a queue.
|
|
1080
|
+
#
|
|
1081
|
+
# All changes are accumulated in memory until the block passed to
|
|
1082
|
+
# {Client#transaction} completes.
|
|
1083
|
+
#
|
|
1084
|
+
# @param [String] queue The name of the queue.
|
|
1085
|
+
# @param [Object, Array<Object>] key A single key or array of composite key parts for the message.
|
|
1086
|
+
# @param [String, IO, StringIO, Hash, Google::Protobuf::MessageExts] payload
|
|
1087
|
+
# The message payload. It is converted the same way as column values
|
|
1088
|
+
# (see {#upsert}), so its type must match the queue's payload column,
|
|
1089
|
+
# such as a `String` for `STRING` or a `StringIO` for `BYTES`:
|
|
1090
|
+
# * `String` - Sent as text.
|
|
1091
|
+
# * `IO`, `StringIO`, `File` - Sent as bytes (Base64-encoded). Ruby has
|
|
1092
|
+
# no bytes type, so wrap binary data in a `StringIO`.
|
|
1093
|
+
# * `Hash` - Serialized to a JSON string.
|
|
1094
|
+
# * `Google::Protobuf::MessageExts` - Serialized and Base64-encoded.
|
|
1095
|
+
# @param [Time, nil] deliver_time The time at which Spanner begins
|
|
1096
|
+
# trying to deliver the message. Optional. If not set, the message is
|
|
1097
|
+
# delivered immediately. A time in the past is replaced with a time
|
|
1098
|
+
# closer to the current time.
|
|
1099
|
+
#
|
|
1100
|
+
# @return [Object, Array<Object>] The key of the message.
|
|
1101
|
+
#
|
|
1102
|
+
# @raise [ArgumentError] If the payload type is unsupported.
|
|
1103
|
+
#
|
|
1104
|
+
# @example Send a message in the same transaction as the row it describes
|
|
1105
|
+
# require "google/cloud/spanner"
|
|
1106
|
+
#
|
|
1107
|
+
# spanner = Google::Cloud::Spanner.new
|
|
1108
|
+
# db = spanner.client "my-instance", "my-database"
|
|
1109
|
+
#
|
|
1110
|
+
# # OrderQueue has a STRING(MAX) payload column.
|
|
1111
|
+
# db.transaction do |tx|
|
|
1112
|
+
# tx.insert "orders", [{ id: 101, status: "NEW" }]
|
|
1113
|
+
# tx.send_message "OrderQueue", 101, "Order payload"
|
|
1114
|
+
# end
|
|
1115
|
+
#
|
|
1116
|
+
def send_message queue, key, payload, deliver_time: nil
|
|
1117
|
+
ensure_session!
|
|
1118
|
+
@commit.send_message queue, key, payload, deliver_time: deliver_time
|
|
1119
|
+
end
|
|
1120
|
+
|
|
1121
|
+
##
|
|
1122
|
+
# Acknowledges a message in a queue, which removes it from the queue.
|
|
1123
|
+
#
|
|
1124
|
+
# All changes are accumulated in memory until the block passed to
|
|
1125
|
+
# {Client#transaction} completes.
|
|
1126
|
+
#
|
|
1127
|
+
# @param [String] queue The name of the queue.
|
|
1128
|
+
# @param [Object, Array<Object>] key A single key or array of composite key parts to match.
|
|
1129
|
+
# @param [Boolean] ignore_not_found If `true`, the ack succeeds even if
|
|
1130
|
+
# the message doesn't exist. Optional. The default is `false`, which
|
|
1131
|
+
# fails the commit with `NOT_FOUND` when the message doesn't exist.
|
|
1132
|
+
#
|
|
1133
|
+
# @return [Object, Array<Object>] The key of the message.
|
|
1134
|
+
#
|
|
1135
|
+
# @example Ack a message in the same transaction as the write it caused
|
|
1136
|
+
# require "google/cloud/spanner"
|
|
1137
|
+
#
|
|
1138
|
+
# spanner = Google::Cloud::Spanner.new
|
|
1139
|
+
# db = spanner.client "my-instance", "my-database"
|
|
1140
|
+
#
|
|
1141
|
+
# db.transaction do |tx|
|
|
1142
|
+
# tx.update "orders", [{ id: 101, status: "PROCESSED" }]
|
|
1143
|
+
# tx.ack_message "OrderQueue", 101
|
|
1144
|
+
# end
|
|
1145
|
+
#
|
|
1146
|
+
def ack_message queue, key, ignore_not_found: false
|
|
1147
|
+
ensure_session!
|
|
1148
|
+
@commit.ack_message queue, key, ignore_not_found: ignore_not_found
|
|
1149
|
+
end
|
|
1150
|
+
|
|
1078
1151
|
##
|
|
1079
1152
|
# @private
|
|
1080
1153
|
# Returns the field names and types for a table.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: google-cloud-spanner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.37.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Moore
|
|
@@ -86,14 +86,14 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '1.
|
|
89
|
+
version: '1.12'
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '1.
|
|
96
|
+
version: '1.12'
|
|
97
97
|
description: google-cloud-spanner is the official library for Google Cloud Spanner
|
|
98
98
|
API.
|
|
99
99
|
email:
|