-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][Performance] Use object instead of dict #43
Comments
Actually, a good catch for situations like this. We can provide a check on the Matcher level: if an Inquiry's attribute is callable or is an object (with some interface) then we can call it and obtain the value, otherwise we just grab the value itself. The caching will be an opt-in on the inquiry-provider side and not baked into vakt anyway. Meanwhile while this feature is not there you can create an Inquiry generator on your side that will calculate the Inquiry dynamically and use cached results if needed. The downside is that you'll need to calculate the attribute values for each Inquiry at least once - depending on the implementation and the use-case it can be reasonably performant. Does it sound good to you? |
Yes,
Not sure what a |
That is correct. I meant exactly this.
It's some sort of a function/class-method that takes some incoming parameters and returns an Inquiry object: let's say it takes Max username as input and returns an inquiry for Max as a subject and a |
Well, there heavy computed attributes maybe dynamic and requires re-eval every time, I am not meant cache them for later re-use. If they are provide as a computed property, in the same round policies evaluation, they maybe hits multiple times, so |
While using vakt, i found that it's hard to build a common inquiry, and since vakt does not support dynamic attribute retrieve, so i have to provide all information to make an Inquiry, and there is where waste coming, some information are not necessary but computed anyway.
If vakt build inquiry using object, then we can make some computing delay or never execute by define them with
@functools.cached_property
For example, policy
A
require attributesubject.is_friend_of_my_friends
(assume it is heavy computing)subject.is_friend_of_my_friends
too, and cache will return, no more extra computingAnd this make vakt more like Attribute-Base-Access-Control, isn’t it?
The text was updated successfully, but these errors were encountered: