TeskaLabs/asab

StorageService: Add missing methods for InMemory provider

Offen

#776 geöffnet am 03.07.2026

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (9 Forks)auto 404
enhancementgood first issue

Repository-Metriken

Stars
 (32 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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