Skip to main content

Module buckets_cmd

Module buckets_cmd 

Source
Expand description

Tauri commands for bucket listing and region discovery.

§Commands

  • buckets_list — list buckets for a profile; SWR cache + validation gate.
  • bucket_region_get — get cached region for one bucket; lazy-resolves on miss.

§Validation gate (AC-8 / round-1 finding #9)

Both commands refuse to serve any data when profile.validated_at is None. The cache itself also enforces this, but the command boundary check is defence-in-depth: a future refactor of the cache must not silently lift the gate.

§SWR behaviour

  • Fresh (within TTL): return cache directly.
  • Stale (past TTL, within SWR window): return stale value immediately and spawn a background task that re-fetches and updates the cache.
  • Missing: fetch synchronously, store, return.
  • force = Some(true): bypass cache; fetch synchronously.

§Region discovery

After a successful bucket list, a background task fires GetBucketLocation for every bucket. Failures are logged as Severity::Warning notifications and do not fail the command. Each successful discovery updates the cache and emits a buckets:updated event.

Functions§

bucket_region_get
Return the cached region for bucket, resolving it lazily on cache miss.
buckets_list
List all buckets for the given profile.
push_bg_warning 🔒
Push a Severity::Warning notification into the log — best-effort.
region_cache_key 🔒
revalidate_buckets 🔒
Re-fetch the bucket list and update the cache + emit events. Called from the background task spawned on a stale cache hit.
spawn_region_discovery 🔒
Spawn a background task that calls GetBucketLocation for every bucket in the list, updating the per-bucket region cache on success and emitting buckets:updated per discovery.