Reduce the number of `Storage` kinds and simplify `StorageFactory`
At the moment there are several types of Storages produced by StorageFactory and their number is growing with the introduction of CatchUpStorage and InboxStorage.
Any SPI user has to put much effort into dealing with similar problems when providing their custom StorageFactory implementation. While in fact most of them can be basically simplified down to three operations:
- Write the
Messagerepresenting either a state of anEntityor just a message, such asInboxMessage. - Read a single
Messageor severalMessageinstances according to the fields stored alongside with theMessagepayload BLOB. - Modify the lifecycle flags associated with the
Message. Most likely, they aredeletedandarchivedflags of anEntity.
So a proposal is to perform the following steps.
- Have a single
Storagekind, capable of storingMessageBLOBs along with some distinct fields. - Re-use the language we already have in
Queryas the definition for field fields, ordering, sorting and limit. Allow theStorageto use this part ofQuerylanguage for reading theMessages from the storage. - Re-implement all the custom lookups we have at the moment in different typed
Storages as a combination ofQuerylanguage predicates built on theRepositorylevel.
In this way, the SPI users will have to provide just a single implementation of the Storage for their custom infrastructure — or to choose among the Spine-provided storage implementations.
@alexander-yevsyukov @dmdashenkov FYI.
This issue is being addressed in the PR #1259.