Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

feat(x-goog-spanner-request-id): introduce AtomicCounter - #1275

Merged
olavloite merged 4 commits into
googleapis:mainfrom
odeke-em:x-goog-spanner-request-id-AtomicCounter
Dec 19, 2024
Merged

feat(x-goog-spanner-request-id): introduce AtomicCounter#1275
olavloite merged 4 commits into
googleapis:mainfrom
odeke-em:x-goog-spanner-request-id-AtomicCounter

Conversation

@odeke-em

Copy link
Copy Markdown
Contributor

This change introduces AtomicCounter, a concurrency/thread-safe counter do deal with the multi-threaded nature of variables. It permits operations:

  • atomic_counter += 1
  • value = atomic_counter + 1
  • atomic_counter.value

that'll be paramount to bringing in the logic for
x-goog-spanner-request-id in much reduced changelists.

Updates googleapis/google-cloud-python#15905
Carved out from PR #1264

This change introduces AtomicCounter, a concurrency/thread-safe
counter do deal with the multi-threaded nature of variables.
It permits operations:
* atomic_counter += 1
* value = atomic_counter + 1
* atomic_counter.value
that'll be paramount to bringing in the logic for
x-goog-spanner-request-id in much reduced changelists.
Updates #1261
Carved out from PR googleapis#1264
@odeke-em
odeke-em requested review from a teamDecember 18, 2024 14:23
@product-auto-labelproduct-auto-labelBot added the size: m Pull request size is medium. label Dec 18, 2024
@product-auto-labelproduct-auto-labelBot added the api: spanner Issues related to the googleapis/python-spanner API. label Dec 18, 2024
Comment threadtests/unit/test_atomic_counter.py Outdated
Comment threadtests/unit/test_atomic_counter.py
Comment threadgoogle/cloud/spanner_v1/request_id_header.py
@olavloiteolavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@odeke-em

Copy link
Copy Markdown
ContributorAuthor

Thank you for the reivew and approval @olavloite! I've updated the tests too. Kindly please help me run the bots too.

@olavloiteolavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@olavloiteolavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@olavloite
olavloite enabled auto-merge (squash) December 19, 2024 19:18
@olavloiteolavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@olavloite
olavloite merged commit f2483e1 into googleapis:mainDec 19, 2024
@release-pleaserelease-pleaseBot mentioned this pull request Dec 19, 2024
@odeke-em
odeke-em deleted the x-goog-spanner-request-id-AtomicCounter branch December 19, 2024 20:38
aakashanandg pushed a commit to aakashanandg/python-spanner that referenced this pull request Jan 2, 2025
…1275)
* feat(x-goog-spanner-request-id): introduce AtomicCounter
This change introduces AtomicCounter, a concurrency/thread-safe
counter do deal with the multi-threaded nature of variables.
It permits operations:
* atomic_counter += 1
* value = atomic_counter + 1
* atomic_counter.value
that'll be paramount to bringing in the logic for
x-goog-spanner-request-id in much reduced changelists.
Updates #1261
Carved out from PR googleapis#1264
* Tests for with_request_id
* chore: remove sleep
* chore: remove unused import
---------
Co-authored-by: Knut Olav Løite <koloite@gmail.com>
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spannerIssues related to the googleapis/python-spanner API.size: mPull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@odeke-em@olavloite@hengfengli@yoshi-kokoro