Skip to content

Refactor storage module into separate files by operation#283

Open
wbssbw wants to merge 4 commits intoobelisk:mainfrom
wbssbw:storage/refactor-apis
Open

Refactor storage module into separate files by operation#283
wbssbw wants to merge 4 commits intoobelisk:mainfrom
wbssbw:storage/refactor-apis

Conversation

@wbssbw
Copy link
Collaborator

@wbssbw wbssbw commented Mar 12, 2026

Summary

Restructures the storage.rs file into a modular package with separate files for each storage operation (get, insert, delete, list). This improves code organization, readability, and maintainability while preserving all existing functionality.

Changes

Code structure:

  • Replaced runtime/plaid/src/functions/storage.rs with a storage/ directory containing:
    • mod.rs - Module exports and shared macros
    • get.rs - get and get_shared operations
    • insert.rs - insert and insert_shared operations
    • delete.rs - delete and delete_shared operations
    • list.rs - list_keys and list_keys_shared operations
  • Added specialized helper functions in insert.rs:
    • fetch_existing_data_size - Retrieves current key-value size
    • check_storage_limit - Validates storage quota before insertion
    • handle_insertion_result - Standardizes result processing

@wbssbw wbssbw marked this pull request as ready for review March 12, 2026 18:35
Copy link
Owner

@obelisk obelisk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also interested in any feedback from @michelemin as he was one of the most recent people to touch this code

Comment on lines +116 to +127
match insert_common(
env_data,
storage,
namespace,
key,
value,
memory_view,
data_buffer,
data_buffer_len,
db.config.size_limit.clone(),
db.used_storage.clone(),
) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tonne of parameters. Do you think there is a way we can make this more clear?

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.

2 participants