TeskaLabs/asab

StorageService: Add missing methods for InMemory provider

Open

#776 opened on Jul 3, 2026

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Python (9 forks)auto 404
enhancementgood first issue

Repository metrics

Stars
 (32 stars)
PR merge metrics
 (PR metrics pending)

Description

Summary

The InMemory storage backend (asab/storage/inmemory.py) does not fully implement the StorageServiceABC interface. MongoDB is the reference implementation; InMemory is missing several features that application code may rely on.

Feature parity

Method / feature MongoDB InMemory ElasticSearch
get_by()
generate_id()
list()

InMemory gaps (this issue):

Method / feature Status
get_by() ❌ raises NotImplementedError()
list() ❌ not implemented

Background

InMemory is used for testing and lightweight deployments. Upsertor modifiers ($set, $inc, $push, $unset, $pull) and AES encrypt/decrypt already work. The main gaps are lookup by field, changestream webhooks, and list().

Current state

  • get_by()asab/storage/inmemory.py:123–130 raises NotImplementedError()
  • list() — not present on InMemory StorageService

Proposed work

  • Implement get_by() (scan in-memory collection by key/value; raise KeyError("NOT-FOUND") when missing, matching MongoDB)
  • Implement list() for basic pagination/sorting parity with MongoDB

References

  • Backend: asab/storage/inmemory.py
  • Reference: asab/storage/mongodb.py
  • Webhook base: asab/storage/upsertor.py
  • Config: [asab:storage:changestream] (webhook_uri, webhook_auth)

Acceptance criteria

  • get_by() returns a document by key/value or raises KeyError("NOT-FOUND")
  • Tests cover get_by() and webhook emission

Contributor guide