Git Product home page Git Product logo

Comments (4)

kolotaev avatar kolotaev commented on May 23, 2024

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?

from vakt.

filwaline avatar filwaline commented on May 23, 2024

Yes, RulesChecker is what i actually aim for, not Inquiry, a new(or updated) checker that allow inquiry's attributes be callable or object will be good enough.


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.

Not sure what a inquiry generator like, and why you think it is a solution.

from vakt.

kolotaev avatar kolotaev commented on May 23, 2024

Yes, RulesChecker is what i actually aim for

That is correct. I meant exactly this.

Not sure what a inquiry generator like, and why you think it is a solution.

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 is_friend_of_my_friends boolean attribute (with a heavy computing done). So this inquiry has all the attributes computed and on the vakt's checker level all the policies will see the already computed value of is_friend_of_my_friends.
On an inquiry-generator level you can leverage the caching or whatever in order not to calculate is_friend_of_my_friends for the same user each time a new request is coming in.

from vakt.

filwaline avatar filwaline commented on May 23, 2024

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 cached_property can prevent re-eval in the same round. (Not a business that vakt should mind)

from vakt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.