Skip to content

Add StorageBackend abstraction with memory implementation#191

Merged
em3s merged 7 commits intomainfrom
feat/storage-backend-interfaces
Feb 9, 2026
Merged

Add StorageBackend abstraction with memory implementation#191
em3s merged 7 commits intomainfrom
feat/storage-backend-interfaces

Conversation

@em3s
Copy link
Contributor

@em3s em3s commented Feb 9, 2026

Summary

  • Introduce StorageBackend interface and StorageTable as the foundation for a pluggable storage layer
  • StorageBackend.getStorageTable(namespace, name)Mono<StorageTable> (URI overload is a default method)
  • DatastoreUri parses datastore:// URIs — SAFE_NAME_PATTERN allows only lowercase, digits, underscore
  • Add MemoryStorageBackend and MemoryStorageTable for in-memory testing
  • Add StorageTableCompatibilityTest abstract test suite to verify any StorageTable implementation meets the contract
  • Purely additive — no existing code modified

Part 1 of 3 for #173. Prerequisite for HBase backend + factory (Part 2) and consumer migration (Part 3 = PR #175).

New Files

Source

File Purpose
StorageBackend.kt Interface: getStorageTable()Mono<StorageTable>, URI overload as default method
StorageTable.kt Interface for key-value operations (get, put, delete, scan, increment, batch, checkAndMutate)
DatastoreUri.kt Parses datastore:// URIs with strict validation (^[a-z0-9_]+$)
MemoryStorageTable.kt In-memory StorageTable backed by ByteArrayStore
MemoryStorageBackend.kt In-memory StorageBackend with isolated stores per namespace

Tests

File Purpose
DatastoreUriTest.kt URI parsing, validation, uppercase/hyphen rejection
StorageTableCompatibilityTest.kt Abstract test suite (contract tests for any StorageTable)
MemoryStorageTableCompatibilityTest.kt Memory impl passes all contract tests
MemoryStorageBackendTest.kt Backend isolation and lifecycle

Test plan

  • ./gradlew build passes (all existing + new tests)
  • Review: interfaces are minimal and complete for existing Label usage patterns
  • Review: DatastoreUri validation covers injection risks

🤖 Generated with Claude Code

Introduce StorageBackend interface and supporting types as the foundation
for a pluggable storage layer, with an in-memory implementation for testing.

New types:
- StorageBackend: Interface for storage backend implementations
- StorageBucket: Interface for key-value operations (get, put, delete, scan, etc.)
- StorageBuckets: Data class holding edge and lock buckets
- DatastoreUri: Utility for parsing datastore:// URIs with input validation
- MemoryStorageBucket: In-memory StorageBucket backed by ByteArrayStore
- MemoryStorageBackend: In-memory StorageBackend with isolated stores per namespace

Tests:
- DatastoreUriTest: URI parsing and validation
- StorageBucketCompatibilityTest: Abstract test suite for StorageBucket contracts
- MemoryStorageBucketCompatibilityTest: Memory implementation passes all contracts
- MemoryStorageBackendTest: Backend-level isolation and lifecycle tests

Part of #173

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request module:engine labels Feb 9, 2026
em3s and others added 6 commits February 9, 2026 12:25
…eTables

- StorageBucket → StorageTable (matches table semantics: scan, get, put)
- StorageBuckets removed (edge/lock distinction is legacy, unused)
- StorageBackend.getBucket() → StorageBackend.open() → Mono<StorageTable>
- MemoryStorageBucket → MemoryStorageTable

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
open() implies close() semantics. getStorageTable() is more explicit
about what it does. URI overload becomes a default method.
Removed deprecated getTable() methods from interface.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removes uppercase letters and hyphens from allowed characters in
datastore URI namespace and table names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…bjectSource

- Rename package v2.engine.storage → engine.storage for new files
- Convert DatastoreUriTest to @ObjectSource (valid/invalid URI cases)
- Convert MemoryStorageBackendTest to @ObjectSource (getStorageTable cases)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>


Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ndTest

- Simplify null checks in MemoryStorageBackendTest using `assertNotNull` for clarity.
- Minor method renaming in StorageTableCompatibilityTest for consistency.
@em3s em3s merged commit fba67f3 into main Feb 9, 2026
9 checks passed
@em3s em3s self-assigned this Feb 9, 2026
@em3s em3s changed the title feat(engine): add StorageBackend abstraction with memory implementation Add StorageBackend abstraction with memory implementation Feb 12, 2026
@em3s em3s deleted the feat/storage-backend-interfaces branch March 1, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant