Coming soon. This is not available yet. The page is a sketch, here for review.
Rindle directly supports the Zero sync framework. Your schemas, queries, mutators and
useQuery components stay the same. The only thing that changes is performance – Rindle is much faster.
Architecture
With Zero, the browser talks to zero-cache, which calls your server and follows Postgres. With Rindle, the browser sends its queries and mutations to your server, which talks to Rindle, and reads its stream straight from Rindle, the same shape as Architecture. Postgres is optional.
Client
Change one import. cacheURL points at your server instead of zero-cache.
-import { Zero } from "@rocicorp/zero";
+import { Zero } from "@rindle/zero";
const zero = new Zero({
schema, mutators, cacheURL: "/api/zero", auth, userID,
});React components keep useQuery from @rindle/zero/react.
Server
Your /query and /mutate endpoints keep their auth, their routes, and the bodies of every query
and mutator. Only the glue changes:
-import {
- handleMutateRequest, handleQueryRequest,
-} from "@rocicorp/zero/server";
+import { createZeroApiServer } from "@rindle/zero/server";
+
+// Reads RINDLE_URL and RINDLE_API_TOKEN
+const api = createZeroApiServer({ schema, queries, mutators });
export async function POST(request: Request) {
const user = await getUser(request); // your auth
- return handleQueryRequest(/* … */);
+ return api.handleQuery(request, { user });
}Your Data
Your data can live in Rindle or stay in Postgres.
- In Rindle. Drop Postgres. Write migrations in SQL, and mutators write to Rindle.
- In Postgres. Keep it. Mutators keep writing to Postgres, and Rindle follows its changes, as zero-cache does today.
Performance
Rindle against the Zero code it ports.
We expect the delta to grow as Rindle continues to be optimized.
Same operations on both sides, ported 1:1. Apple Silicon. Source: BENCHMARKS.md (the MemorySource and TableSource head-to-heads).
| Operation | Rindle (Rust) | Zero (TypeScript) | Speedup |
|---|---|---|---|
| scan 1,000 rows | 3.6 µs | 110 µs | 31× |
| filtered fetch (~100 rows) | 0.8 µs | 12.8 µs | 16× |
| start from middle (~500 rows) | 2.4 µs | 58 µs | 24× |
| insert + delete a row | 0.11 µs | 3.1 µs | 28× |
| edit a row | 0.28 µs | 3.9 µs | 14× |
| Operation | Rindle (Rust) | Zero (TypeScript) | Speedup |
|---|---|---|---|
| scan 1,000 rows | 99 µs | 673 µs | 6.8× |
| filtered fetch (~100 rows) | 17 µs | 80 µs | 4.7× |
| start from middle (~500 rows) | 72 µs | 369 µs | 5.2× |
| insert + delete a row | 2.9 µs | 7.6 µs | 2.6× |
| edit a row | 2.7 µs | 8.1 µs | 3.0× |