Storage cannot be implemented by others
The current Storage interface returns Prefix structs. But the Prefix struct contains private fields which cannot be filled/returned by external implementations as they do not see this fields. But the Prefix implementation relies on these fields and their correctness.
i see the following options:
- extend the
Storageinterface with methods for manipulating the current private fields - create a new
StoragePrefixwhich is returned/consumed by a storage and contains only the data from the storage. thePrefixalways copies the data to it's own fields. - make the interface private and remove the
NewWithStoragefuction. new storage backends have to be provided by the library and must provided as PR's
i'd propose the third option as atm i cannot see any other implementations for Storage from outside of our project.
I agree with your findings and propose the third option as well, having support for different storages was introduced more from the abstraction and testing perspective.
As we already have support for plenty of databases implemented, i am closing this.