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

@Alnusjaponica Alnusjaponica commented Sep 27, 2026 •

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. As with thread::Builder::new(), XxxBuilder::new() is the only entry point (consistent with PedAnovaBuilder in #262).

let storage = InMemoryStorageBuilder::new()
    .apply_discard(true)
    .attr_format(AttrFormat::Json)
    .build();

let storage = SQLite3StorageBuilder::new(file_path)
    .apply_discard(true)
    .build()?;   // Result

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

Changes

  • Add InMemoryStorageBuilder (with Default), SQLite3StorageBuilder, and JournalStorageBuilder, exposing new(), chainable setters (apply_discard, attr_format), and build()
  • Remove InMemoryStorageOptions, SQLite3StorageOptions, JournalStorageOptions and new_with_option/new_with_options
  • Keep new on InMemoryStorage/SQLite3Storage/JournalStorage with the existing signatures; it now delegates to the builders
  • Update the pyo3 bindings (including ToRustStorage's cache) to construct storages through the builders
  • Update a doc comment in cache.rs that referenced the removed options structs

Verification

  • cargo test --locked --all-features — all pass (including new doctests)
  • cargo test --locked -- --ignored (from rustuna_storage, with Optuna installed) — 6 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/ — 706 passed, 16 skipped

🤖 Generated with Claude Code

@Alnusjaponica
Alnusjaponica marked this pull request as draft September 28, 2026 02:21
@c-bata c-bata self-assigned this Oct 5, 2026
@c-bata

c-bata commented Oct 5, 2026

Copy link
Copy Markdown
Member

@Alnusjaponica Is this PR ready for review?

@Alnusjaponica
Alnusjaponica marked this pull request as ready for review November 4, 2026 10:06
@Alnusjaponica
Alnusjaponica marked this pull request as draft November 6, 2026 05:33
@c-bata c-bata removed their assignment Nov 9, 2026
@Alnusjaponica
Alnusjaponica force-pushed the feat/storage-builder branch 2 times, most recently from c8b38d5 to b8bebf7 Compare November 19, 2026 02:38

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants