TeskaLabs/asab

StorageService: Add missing methods for InMemory provider

Aperta

#776 aperta il 3 lug 2026

 (0 commenti) (0 reazioni) (0 assegnatari)Python (9 fork)auto 404
enhancementgood first issue

Metriche repository

Star
 (32 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor