Expand description
First-class laravel-rust integration for LiteBucket — durable SQLite on S3, Cloudflare R2,
and Laravel Cloud Object Storage with zero sidecars and zero proxies.
§Quick Start (1 Line)
ⓘ
use laravel_litebucket::prelude::*;
laravel::Application::configure()
.with_litebucket()
.with_routing(...)
.run();Or customize fluently in a closure:
ⓘ
use laravel_litebucket::prelude::*;
laravel::Application::configure()
.with_litebucket_using(|b| {
b.sync_mode(SyncMode::Batched)
.disk_cache_mb(64)
.write_lease(true)
.compact_every(32);
})
.with_routing(...)
.run();§Multi-Tenant Pairing (laravel-tenanted + LiteBucket in 1 Line)
ⓘ
use laravel_litebucket::prelude::*;
use laravel_tenanted::WithTenancy;
laravel::Application::configure()
.with_litebucket()
.with_tenancy_using(|t| {
t.litebucket()
.subdomain("example.com");
})
.with_routing(...)
.run();t.litebucket() automatically wires tenanted_database_url, s3_tenant_exists,
s3_discover_tenants, and s3_shred_tenant for "tenants/{tenant}/main".
Use t.litebucket_from_env() to keep local SQLite in dev/tests and activate LiteBucket
whenever LITEBUCKET_VFS=1 is set.
Modules§
- prelude
- Common imports for 1-line LiteBucket setup (
use laravel_litebucket::prelude::*;).
Structs§
- CdcCommit
Event - Clone
Report - Compact
GcReport - Encryption
Key - 256-bit client-side encryption key for AES-256-GCM page encryption.
Caches the pre-expanded
Aes256Gcmkey schedule & GHASH table once per key so per-page encrypt/decrypt avoids redundant cipher initialization! Optionally carries aprevious_cipher(LITEBUCKET_PREVIOUS_ENCRYPTION_KEY) for zero-downtime key rotation: new writes always encrypt withcipher, while reads transparently decrypt old chunks/frames encrypted withprevious_cipheruntillitebucket rekeyfinishes. Supports RFC 5869 HKDF-SHA256 per-tenant key derivation (derive_for_tenant) for cryptographic tenant isolation in database-per-tenant architectures. - Inspect
Report - Lite
Bucket Builder - Fluent configuration builder passed to
WithLiteBucket::with_litebucket_using. - Lite
Bucket Service Provider - Drop-in
laravel-rustServiceProvider: - LtxFrame
Info - Shred
Report - Sqlite
Clone sqlite:clone— clone an S3/R2 prefix (zero-download S3 CopyObject or redacted SQL clone).- Sqlite
Compact - Compact the LiteBucket LTX history into a snapshot via monotonic CAS on
manifest.jsonand garbage-collect superseded LTX/snapshot files outside--retain. - Sqlite
Doctor - Live S3/R2 doctor check: verifies bucket access,
If-None-Match: *412 fencing,If-MatchETag CAS, HTTP Range 206 reads, DELETE, and measures RTT. - Sqlite
History sqlite:history— list restorable PITR transactions and ISO-8601 timestamps in S3/R2.- Sqlite
Inspect sqlite:inspect— inspect bucket health, size, chunks, PITR window, encryption, and active lease.- Sqlite
Pitr - Run a read-only point-in-time recovery (PITR) query pinned at a historical
--txidor--attimestamp. - Sqlite
Rekey sqlite:rekey— zero-downtime AES-256-GCM key rotation (LITEBUCKET_PREVIOUS_ENCRYPTION_KEY->LITEBUCKET_ENCRYPTION_KEY).- Sqlite
Restore sqlite:restore— non-destructive in-place PITR rollback (appends historical state athead + 1).- Sqlite
Shred sqlite:shred— permanently delete every S3/R2 object under--prefix(GDPR offboarding).- Sqlite
Status - Print live S3/R2 lease status and LiteBucket LTX chain status.
- Sqlite
Verify - Cold-boot verify a LiteBucket database in S3/R2: checks
PRAGMA integrity_checkand full CRC64 LTX chain. - VfsStats
- Write
Forwarding Middleware - First-class
laravel::http::Middlewarefor zero-config multi-replica horizontal scaling!
Enums§
- Sync
Mode - Durability / commit mode for the
s3ltxVFS:
Traits§
- Lite
Bucket Tenancy - Extension trait adding 1-line LiteBucket storage wiring onto
laravel_tenanted::TenancyBuilder. - With
Lite Bucket - Extension trait adding 1-line
.with_litebucket()and.with_litebucket_using(|b| ...)directly ontolaravel::Application::configure().
Functions§
- all_
open_ dbs_ prometheus_ metrics - Render Prometheus exposition metrics (
text/plain; version=0.0.4) for all open LiteBucket DBs. - all_
open_ dbs_ stats - Snapshot
VfsStatsfor every currently openlitebucketdatabase in this process. - current_
write_ owner_ addr - Fast ~50 ns lookup for write-forwarding middleware: returns
Some(peer_http_url)if another live replica currently holdswrite_lock.jsonand advertises anowner_addr, orNoneif this process is the active writer (or no peer owner is known). - database_
url - Build a
sqlx-sqlite/laravel-rust-compatible LiteBucket URL for a single database (e.g."central/main"or"app/main"). RespectsLITEBUCKET_SYNC_MODE(defaultbatched). - database_
url_ strict - Build a
sqlx-sqlite/laravel-rust-compatible LiteBucket URL using synchronousSyncMode::Strict(RPO = 0on every commit — ideal for central auth/organization registries and billing ledgers). - flush_
all_ open_ dbs - Synchronously flush all staged AND in-flight write-back buffers AND release distributed write
leases across every open
litebucketdatabase in this process. Called automatically at process exit (atexit) and recommended inSIGTERMhandlers so rolling deploys and hibernations hand off cleanly. - flush_
db - Force an immediate S3/R2 durability barrier (
PRAGMA litebucket_flush) on the activelaravel-rustdatabase connection — givesRPO = 0on critical transactions (e.g., payments/checkouts) while keeping sub-millisecondSyncMode::Batchedeverywhere else. - flush_
prefix - Synchronously flush staged AND in-flight write-back buffers for a single open
litebucketdatabase matchingprefixwithout releasing its distributed write lease. - flush_
staged_ dbs - Synchronously flush all staged AND in-flight write-back buffers across every open
litebucketdatabase in this process without releasing distributed write leases. - forward_
to_ write_ owner - Forward an incoming Axum request over private LAN to the replica currently holding
write_lock.json, taggingX-LiteBucket-Forwardedto prevent forwarding loops. - metrics_
prometheus - Render Prometheus metrics (
text/plain; version=0.0.4) for every open LiteBucket database in thislaravel-rustprocess — wire directly into aGET /metricsroute in 1 line. - s3_
discover_ tenants - Plug-and-play
laravel-tenanteddiscover_tenantshook backed by S3/R2! - s3_
shred_ tenant - Plug-and-play
laravel-tenantedon_deletehook backed by S3/R2! - s3_
tenant_ exists - Plug-and-play
laravel-tenantedcheck_existshook backed by S3/R2! - sanitize_
tenant_ id - Strict InfoSec tenant identifier validation:
- tenanted_
database_ url - Build a drop-in LiteBucket SQLite URL template for
laravel-tenanted(exact mirror of Rails’LiteBucket.tenanted_database_uri("tenants/%{tenant}/main")). - tenanted_
database_ url_ with_ opts - Variant of
tenanted_database_urlallowing explicit toggle of per-tenant HKDF encryption. - with_
retry - Multi-writer optimistic concurrency helper for
SyncMode::Strict: runs an async write closure and automatically catches up (PRAGMA litebucket_catch_up) and retries with brief backoff if another container won the S3If-None-Match: *race (SQLITE_BUSY/database is locked). - write_
forwarding_ middleware - Native in-process Axum middleware for horizontal multi-replica scaling!
- write_
forwarding_ middleware_ with_ resolver - Variant of
write_forwarding_middlewareaccepting a customowner_resolver(useful for multi-DB prefixes or deterministic testing). - write_
owner_ addr - Fast (~50 ns) lookup returning the private LAN URL of the peer replica currently holding
write_lock.json, orNoneif this replica owns the write lease locally. - write_
owner_ addr_ for - Scoped variant of
write_owner_addrfiltering to a specific database prefix.