Skip to content

docs(storage): add Rapid Cache samples - #7346

Draft
sahusneha2004 wants to merge 2 commits into
mainfrom
storage-rapid-cache-samples-rust
Draft

sahusneha2004 wants to merge 2 commits into
mainfrom
storage-rapid-cache-samples-rust

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown

Adds Storage Control samples for Rapid Cache: create, get, list, update (TTL through a FieldMask), and disable.

Region tags:

  • storage_control_create_rapid_cache
  • storage_control_get_rapid_cache
  • storage_control_list_rapid_caches
  • storage_control_update_rapid_cache
  • storage_control_disable_rapid_cache

Notes:

  • create uses cache_type = "rapid-cache-ultra" and does not set a name. The service assigns the cache ID, so the driver finds it by listing caches and parsing the name.
  • disable starts the long-running operation and does not wait for it. The cache reaches the disabled state within seconds, but the operation only completes once the cache is fully removed, which can take more than 30 minutes. The driver polls get_rapid_cache until the state is disabled.
  • Unlike the Anywhere Cache samples, these samples print specific fields instead of {:?}, to match the samples in other languages.
  • The test bucket is a regional HNS + UBLA bucket in the region of GOOGLE_CLOUD_RUST_TEST_ZONE (default us-central1-a).
  • The new rapid_cache_examples integration test is gated behind skipped-integration-tests, like the Anywhere Cache examples.
  • Bucket cleanup is best-effort. Deleting the bucket returns FAILED_PRECONDITION ("The bucket you tried to delete has Rapid Cache Ultra") for a long time after the cache is disabled. The test retries for about 2 minutes, then leaves the bucket for the stale bucket cleanup, which now also disables rapid caches.
  • The API is in the released google-cloud-storage 1.21.0.

Testing: cargo fmt --check and cargo clippy --all-targets --all-features -- --deny warnings pass. I also ran the full integration test once against a live project:

cargo test -p storage-samples --features run-integration-tests,skipped-integration-tests --test integration rapid_cache_examples

Internal bug: b/482946642

Update: aligned with googleapis/google-cloud-java#14529

The samples and the test now follow the reference integration test (ITRapidCacheTest.java). This replaces the create and disable notes above.

  • create: sets the cache name explicitly (projects/_/buckets/{bucket}/rapidCaches/{zone}; the backend requires the cache ID to equal the zone), with cache_type = "rapid-cache-ultra" and a 24h TTL (86400s).
  • disable: now waits for the long-running operation with .poller().until_done() instead of returning right away.
  • Driver: waits 20s after the bucket is created, uses cache_id = zone (no more listing to find the service-assigned ID), and checks that the cache is running with the right cache type after create, that list returns it, and that the TTL is 172800s after update.
  • Driver: wraps the disable sample in tokio::time::timeout(600s). If it times out, it calls get_rapid_cache and accepts the disabled state, so the test never hangs.

Testing: cargo fmt --check, cargo clippy -p storage-samples --all-targets --all-features -- --deny warnings, and one live run of rapid_cache_examples (passed; the disable operation hit the 600s timeout and the cache state was disabled).

Adds create, get, list, update and disable Rapid Cache samples for Storage Control, with an integration test gated behind skipped-integration-tests. b/482946642

[Generated-by: AI]
@product-auto-label product-auto-label Bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Nov 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support and examples for managing Rapid Caches in the Google Cloud Storage Control service. It adds new modules and sample code for creating, disabling, getting, listing, and updating rapid caches. Additionally, it integrates these examples into the integration test suite and updates the bucket cleanup logic to handle rapid caches. I have no feedback to provide as there are no review comments and the implementation is clean.

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.53%. Comparing base (d6bfdda) to head (6f72dd8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7346      +/-   ##
==========================================
- Coverage   97.53%   97.53%   -0.01%     
==========================================
  Files         334      334              
  Lines      142387   142387              
==========================================
- Hits       138879   138878       -1     
- Misses       3508     3509       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642

[Generated-by: AI]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. storage-sample-architect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant