Skip to content

Introduce builders for the storage implementations - #260

Draft
Alnusjaponica wants to merge 1 commit into
mainfrom
feat/storage-builder
Draft

Alnusjaponica wants to merge 1 commit into
mainfrom
feat/storage-builder

Conversation

@Alnusjaponica

Copy link
Copy Markdown
Contributor

Summary

Replace the XxxStorageOptions/new_with_option(s) construction pattern with builders following the API style of std::thread::Builder: settings are configured by chaining setter methods and the storage is created with build.

let storage = InMemoryStorage::builder()
    .apply_discard(true)
    .build();

let storage = SQLite3Storage::builder(file_path)
    .apply_discard(true)
    .build()?;   // Result

let storage = JournalStorage::builder(Box::new(backend))
    .apply_discard(true)
    .build()?;   // Result

Changes

  • Add InMemoryStorageBuilder, SQLite3StorageBuilder, and JournalStorageBuilder (with Default where they have no required arguments), exposing builder(), chainable setters, and build()
  • Remove InMemoryStorageOptions, SQLite3StorageOptions, JournalStorageOptions and new_with_option/new_with_options
  • Keep new for backward compatibility; it now delegates to the builders
  • SQLite3Storage/JournalStorage/CachedStorage also keep their existing new signatures
  • Update the pyo3 bindings to construct storages through the builders
  • Update a doc comment in cache.rs that referenced the removed options structs

Verification

  • cargo test --all-features — 275 tests pass (including new doctests)
  • cargo test -p rustuna_storage --locked -- --ignored (from rustuna_pyo3) — 3 pass
  • cargo clippy --locked --workspace --lib --bins --tests --examples --all-features -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • Python: uv run --no-sync pytest tests/ — 701 pass

Replace the `XxxStorageOptions`/`new_with_option(s)` construction pattern
with builders following the API style of `std::thread::Builder`: settings
are configured by chaining setter methods and the storage is created with
`build`.

- `InMemoryStorageBuilder`: `InMemoryStorage::builder().apply_discard(true).build()`
- `SQLite3StorageBuilder`: `SQLite3Storage::builder(file_path).apply_discard(true).build()`
- `JournalStorageBuilder`: `JournalStorage::builder(backend).apply_discard(true).build()`

`InMemoryStorageOptions`, `SQLite3StorageOptions`, `JournalStorageOptions`
and `new_with_option`/`new_with_options` are removed. `new` is kept for
backward compatibility and now delegates to the builders. The pyo3 bindings
construct storages through the builders as well.
@Alnusjaponica
Alnusjaponica marked this pull request as draft September 28, 2026 02:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant