Reuse badger disk storage for other purposes #136
-
My use case is that I have a component that uses OPA in library mode (as embedded component). Coincidentally my project storage is also backed up by BadgerDB. Therefore it seems quite natural and simplifying to use just one instance of BadgerDB on the disk. So there are two updates in my approach: it is possible to provice BadgerDB DB instance that was created externally in other parts of the code and it is possible to add common, global prefix for all keys inserted by OPA storage which gives effectively a namespace so conflicts with other parts of the code can be avoided. Do you think such addition would be valuable for general use? Currently I'm hacking over copy of disk storage implementation (copied directly from the project into my codebase) but I could easily provide Pull Request with necessary changes based on my work. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Honestly, this is not something we've thought about much. How are you using OPA? Through the SDK? Or via the I think we'd hesitate introducing any sort of "bring your own badgerdb" feature any time soon. It's still early days for the disk storage in OPA, and I'd be cautious with this -- we don't know how to deal with migrations properly, for example, and having to consider other users of the same database instance would definitely complicate things. It's easier to deal with a database you own completely. But all that said, you could write your own storage implementation that would use your shared badgerdb instance, with the prefixing dealt with as you see fit. Btw, do you know other badger-embedding projects that offer this kind of functionality? 🤔 |
Beta Was this translation helpful? Give feedback.
Honestly, this is not something we've thought about much.
How are you using OPA? Through the SDK? Or via the
rego
packages, or something even lower-level?I think we'd hesitate introducing any sort of "bring your own badgerdb" feature any time soon. It's still early days for the disk storage in OPA, and I'd be cautious with this -- we don't know how to deal with migrations properly, for example, and having to consider other users of the same database instance would definitely complicate things. It's easier to deal with a database you own completely.
But all that said, you could write your own storage implementation that would use your shared badgerdb instance, with the prefixing dealt wit…