prolly-store-spanner
Cloud Spanner-backed remote store adapter for prolly-map.
This crate implements RemoteStoreBackend using gcloud-spanner. Use it
through RemoteProllyStore and AsyncProlly when you need globally consistent
SQL-backed Prolly tree storage on Google Cloud Spanner.
Installation
The client dependency is listed explicitly because applications construct the
ClientConfig passed to the adapter:
[]
= "0.4"
= "0.3.0"
= { = "gcloud-spanner", = "=1.8.1" }
= { = "1", = ["macros", "rt-multi-thread"] }
When to use it
Use this adapter when your application already runs on Cloud Spanner or when named roots need strongly consistent, horizontally scalable SQL storage. It is a good fit for multi-region metadata, durable branch heads, and services where Spanner availability and transaction semantics are more important than local single-node latency.
Use PostgreSQL/MySQL for simpler single-region SQL deployments. Use Redis for cache-like state. Use DynamoDB or Cosmos DB when your cloud platform is AWS or Azure and you prefer their native NoSQL services.
Table model
The adapter expects these GoogleSQL tables:
(
Cid BYTES(32) NOT NULL,
Node BYTES(MAX) NOT NULL
) PRIMARY KEY (Cid);
(
Namespace BYTES(MAX) NOT NULL,
HintKey BYTES(MAX) NOT NULL,
Value BYTES(MAX) NOT NULL
) PRIMARY KEY (Namespace, HintKey);
(
Name BYTES(MAX) NOT NULL,
Manifest BYTES(MAX) NOT NULL
) PRIMARY KEY (Name);
The same DDL is exposed as SPANNER_SCHEMA.
Setup
Set the Spanner database resource name:
Create the tables using gcloud:
Authentication depends on gcloud-spanner configuration. In the examples and
tests, set PROLLY_STORE_SPANNER_AUTH=1 to call ClientConfig::with_auth().
Basic usage
use ClientConfig;
use ;
use SpannerBackend;
# async
Diff and merge
# use ;
# use SpannerBackend;
# async
Operational notes
- The adapter does not create tables. Apply DDL before startup.
- Strict commits validate named-root preconditions and apply node and root mutations in one Spanner read-write transaction.
batch_put_nodesis applied as Spanner mutations.- There is no adapter-level key prefix. Use distinct named-root prefixes for tenants or environments, and isolate databases when you need full physical separation.
- Node garbage collection should be coordinated at the application layer after deciding which named roots to retain.
Running the example
From the standalone repository root:
The example writes a base tree, diffs and merges branches, resolves a conflict, publishes a unique named root, and loads it back.
Testing
The integration test runs when PROLLY_STORE_SPANNER_DATABASE is set. Set
PROLLY_STORE_SPANNER_AUTH=1 to use application-default authentication; omit it
when the client environment already supplies the intended emulator or channel
configuration:
Use a dedicated test database or distinct named-root prefix. The adapter does not provide a backend-wide key prefix or cleanup helper.
See the prolly-map API documentation for the
async map, transaction, diff, and merge APIs used with this backend.