Best way to use Rego Go lib to process policies with changing data and input #214
-
I'm using the Go lib to build a policy checker (an API GW extension) which fetches attributes for an identity (SPIFFE SAN) from an external DB and adds it along with the usual input parameters ( path, method, etc) to the My current implementation does it via submitting the call attributes via I'm wondering if it's the best way to do it from the memory (heap allocs) and performance standpoint. I guess Any ideas and shared experience are highly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The docs on external data mostly apply to the golang lib use case, too. It usually boils down to how often your data changes whether You can think of OPA's store as a workbench: what should be at hand for policy evaluation, but isn't different for each and every input you feed into it, could very well live in the store. |
Beta Was this translation helpful? Give feedback.
-
Thank you, @srenatus! You've confirmed my understanding. In my case I need to change the "data" ( i.e. context for the Policy eval) for every evaluation. So the easiest is to add it to the I should probably figure out a caching strategy for that context data (it actually shouldn't change that often, but still has to stay consistent with the DB) then |
Beta Was this translation helpful? Give feedback.
The docs on external data mostly apply to the golang lib use case, too.
It usually boils down to how often your data changes whether
input
ordata
is the right place. How large is your data? Unless it's very very large, updating the inmem store for data that doesn't change too frequently is a good approach. It'll do heap allocations, it's in memory after all, but it won't do that for every policy evaluation.You can think of OPA's store as a workbench: what should be at hand for policy e…