core-java
core-java copied to clipboard
Reduce the number of `Storage` kinds and simplify `StorageFactory`
At the moment there are several types of Storage
s 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
Message
representing either a state of anEntity
or just a message, such asInboxMessage
. - Read a single
Message
or severalMessage
instances according to the fields stored alongside with theMessage
payload BLOB. - Modify the lifecycle flags associated with the
Message
. Most likely, they aredeleted
andarchived
flags of anEntity
.
So a proposal is to perform the following steps.
- Have a single
Storage
kind, capable of storingMessage
BLOBs along with some distinct fields. - Re-use the language we already have in
Query
as the definition for field fields, ordering, sorting and limit. Allow theStorage
to use this part ofQuery
language for reading theMessage
s from the storage. - Re-implement all the custom lookups we have at the moment in different typed
Storage
s as a combination ofQuery
language predicates built on theRepository
level.
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.