-
-
Notifications
You must be signed in to change notification settings - Fork 558
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
Allow configuring options per Execute calls #738
Comments
In RavenDB we have 3 flows for this:
If 1. will return the old value, then 2. and 3. could be easily handled by us, no need to for a built-in mechanism for that. As @lahma wrote, the reasoning is the source of the script, when it is an internal one (e.g. parsing our built-in scripts or a library - done on engine initialization) then we do not care about the max statements constraint, but when the script is passed by the user, then we need to have some safe guards. |
Hey @ppekrol sorry for the long wait. I think I've solved this in #789 where we also want to disable constrains when initializing engine pool. Basically for your use case: var options = new Options(); // the defaults you want to go with
var engine = new Engine();
using (engine.ActivateTemporaryConstraints(Array.Empty<IConstraint>()))
{
// do a lot of things with engine
}
var tempConstraints = new Options().MaxStatements(42).LimitMemory(1024).CancellationToken(token).BuildConstraints();
using (engine.ActivateTemporaryConstraints(tempConstraints))
{
// allow calling engine with limited resources
} Please note that we are also in that PR building a safer (but probably not bullet proof) context that is able to dispose registered variables etc. API may change and all feedback welcome! |
Hi @lahma Will there be an ability to change just one constraint? Now I see you need to create new options for those each time. Can options be cloned maybe? What do you think? |
My thinking was that you have like three sets of constraints pre-built. You can build those as static arrays using the example Options and then just switch between them during your specific use case. There's no need to build them every time. In other words you would switch between constraint sets instead of replacing constraint in one set. |
And correcting previous, because constraints have state, they need to be build per use case, but the options are static. |
I'm closing this as there are workarounds and this would be non-trivial to implement. |
Allow overriding defaults for max statements for example for trusted scripts, otherwise would run with engine level constraints. This would probably mean creating a context that would pass through statement calls, context would have options which is engine default or user provided.
Relates to RavenDB's need to change max statement on use case basis.
The text was updated successfully, but these errors were encountered: