Skip to content

feat(spanner): add send_message and ack_message to Commit - #262

Merged
torreypayne merged 3 commits into
mainfrom
queues/2-commit
Oct 21, 2026
Merged

torreypayne merged 3 commits into
mainfrom
queues/2-commit

Conversation

@torreypayne

@torreypayne torreypayne commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Adds Commit#send_message(queue, key, payload, deliver_time: nil) and Commit#ack_message(queue, key, ignore_not_found: false). Each adds a Send or Ack mutation and returns the key.

  • key is one message key: a scalar, or an array of the key's column values for a composite primary key. (Commit#delete reads an array as several keys instead.)
  • Payloads are converted like column values, so binary payloads are passed as StringIO.
  • The methods aren't named send because that would override Object#send.

Part 2 of 5, split out of #260. Transaction support comes in part 3.

@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Oct 12, 2026
@torreypayne
torreypayne added this pull request to stack #266 October 12, 2026 19:55
@torreypayne
torreypayne marked this pull request as ready for review October 13, 2026 20:17
@torreypayne
torreypayne requested a review from a team as a code owner October 13, 2026 20:17

@quartzmo quartzmo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The unit tests pass on Ruby 3.2 through 4.0 locally. Two small notes:

  • The description says "Keys work like Commit#delete", but for an Array they don't: delete "T", [1, 2] deletes two keys, while send_message "Q", [1, 2], ... sends one composite key (1, 2). The method docs are right; it's only the description, which does matter if it ends up in the squash commit.
  • FYI, the new doctest examples fail locally with unmocked method :create_session, but so do 321 of 365 examples on main: the doctest mocks still stub batch_create_sessions. CI doesn't run doctest, so I think you can consider this out of scope for this PR. Just mentioning it.

Comment thread google-cloud-spanner/lib/google/cloud/spanner/send_options.rb Outdated
@torreypayne

Copy link
Copy Markdown
Member Author

Thanks for the careful read. I fixed the description: key is a single message key, so an array is one composite key, while delete takes a list of keys (see key_set). Agreed that the doctest failures predate this PR; I'll leave them for a separate one.

@torreypayne
torreypayne requested a review from quartzmo October 20, 2026 18:08

@quartzmo quartzmo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending fully green CI.

Base automatically changed from queues/1-deps to main October 20, 2026 23:21
…arguments

Replace the SendOptions and AckOptions classes with keyword arguments, as
agreed on #262. Adding an optional keyword later doesn't break callers,
and an unknown keyword still raises ArgumentError.

Also fix the key_list_value doc: it converts one key, not a list of keys.
The examples wrapped text in a StringIO, which is only right for a queue
with a BYTES payload column. On a STRING column the gem would send the
Base64 text. Use a String and say the queue's payload column is
STRING(MAX), and add a separate BYTES example that wraps binary data.
@torreypayne
torreypayne merged commit 7bf1746 into main Oct 21, 2026
22 checks passed
@torreypayne
torreypayne deleted the queues/2-commit branch October 21, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants