snapdir_stores/lib.rs
1//! snapdir stores library.
2//!
3//! Storage backends for snapdir snapshots plus the store-routing and
4//! external-store shim that implement snapdir's store dispatch:
5//!
6//! - [`FileStore`] — the in-process `file://` backend.
7//! - [`S3Store`] — the native AWS-SDK `s3://` backend (ring rustls).
8//! - [`B2Store`] — the native AWS-SDK `b2://` backend, pointed at Backblaze
9//! B2's S3-compatible endpoint (wraps [`S3Store`] with a custom endpoint).
10//! - [`GcsStore`] — the native `google-cloud-storage` `gs://` backend
11//! (ring rustls; ADC credential chain).
12//! - [`router`] — scheme → adapter resolution, including the hardcoded
13//! `gs://`→`gcs` special case for the Google Cloud Storage adapter.
14//! - [`shim`] ([`ExternalStore`]) — the emit-command shim that dispatches
15//! third-party `snapdir-<name>-store` binaries via the documented
16//! `get-manifest-command` / `get-fetch-files-command` / `get-push-command`
17//! contract.
18//! - [`limits`] ([`BackendLimits`], [`for_scheme`]) — the published per-backend
19//! request-rate / bandwidth caps (rate caps only; no retry policy) keyed by
20//! storage scheme, used to pace transfers under each provider's documented
21//! limits.
22//! - [`transfer`] ([`TransferConfig`], [`RateLimiter`], [`run_concurrent`]) —
23//! the concurrency + bandwidth-limiting foundation each store carries via a
24//! [`TransferConfig`] for the (later) concurrent transfer loops.
25//! - [`retry`] ([`RetryPolicy`], [`retry_async`], [`retry_blocking`]) — a pure,
26//! injectable full-jitter exponential-backoff engine (no real clock/sleep of
27//! its own; the [`Jitter`] source and [`AsyncSleeper`]/[`BlockingSleeper`] are
28//! injected). SDK-agnostic over an [`Attempt`] outcome; wiring into the
29//! S3/GCS/B2 call sites is a later gate.
30//! - [`adaptive`] ([`AdaptiveGate`], [`AdaptiveController`]) — pure, injectable
31//! adaptive control: a resizable concurrency permit pool (async + blocking)
32//! plus a deterministic slow-start/AIMD controller that turns injected op
33//! samples + system metrics into a concurrency limit and target byte-rate
34//! (wiring into the live transfer loops is a later gate).
35//! - [`stream`] ([`StreamStore`]) — object/manifest-level, content-addressed,
36//! verified read/write primitives (the foundation for store-to-store sync),
37//! implemented for [`FileStore`], [`S3Store`], [`GcsStore`], and [`B2Store`].
38//! - [`pack`] ([`write_pack`], [`read_pack`], [`PackSink`]) — the SNAPPACK 1
39//! wire stream behind the `ssh://` acceleration plumbing
40//! (`snapdir send-pack | ssh … 'snapdir receive-pack'`): `obj` records
41//! stream through incremental BLAKE3 verification (O(1) memory into a
42//! [`FileSink`]), the manifest rides last and commits only after the `end`
43//! trailer, so truncation can never publish a snapshot.
44//! - [`sync`] ([`sync_snapshot`], [`SyncReport`]) — streaming store-to-store
45//! snapshot copy: walks a source manifest and copies its raw objects
46//! source → dest through memory only (no local filesystem staging),
47//! parallelized across a rayon pool and throttled by a
48//! [`BlockingRateLimiter`](transfer::BlockingRateLimiter); writes the manifest
49//! last (all-or-nothing).
50
51pub mod adaptive;
52pub mod b2_store;
53pub(crate) mod fetch;
54pub mod file_store;
55pub mod gcs_store;
56pub mod limits;
57pub mod pack;
58pub(crate) mod push;
59pub mod retry;
60pub mod router;
61pub mod s3_store;
62pub mod shim;
63pub mod stream;
64pub mod sync;
65pub mod transfer;
66pub(crate) mod util;
67
68pub use adaptive::{
69 p95_object_size, AdaptiveController, AdaptiveGate, AdaptivePolicy, ControllerDriver, Decision,
70 OpResult, OpSample,
71};
72pub use b2_store::B2Store;
73pub use file_store::FileStore;
74pub use gcs_store::{GcsLocation, GcsStore};
75pub use limits::{for_scheme, BackendLimits};
76pub use pack::{
77 is_hex64, read_pack, write_pack, FileSink, PackReadReport, PackSink, PackWriteReport,
78 StreamSink, MAX_HEADER_BYTES, MAX_MANIFEST_BYTES, WIRE_CAPS, WIRE_MAGIC, WIRE_VERSION,
79};
80pub use retry::{
81 parse_retry_after, retry_async, retry_blocking, retry_network, AsyncSleeper, Attempt,
82 BlockingSleeper, DefaultJitter, FixedJitter, Jitter, RetryPolicy, ThreadSleeper, TokioSleeper,
83};
84pub use router::{resolve_adapter, Adapter, RouteError};
85pub use s3_store::{S3Location, S3Store};
86pub use shim::ExternalStore;
87pub use stream::StreamStore;
88pub use sync::{sync_snapshot, SyncReport};
89pub use transfer::{
90 classify_error, run_adaptive, run_concurrent, AdaptivePolicy as TransferAdaptivePolicy,
91 BlockingRateLimiter, RateLimiter, TransferConfig,
92};