-
Notifications
You must be signed in to change notification settings - Fork 34
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
V2 Stored Procedure Support #697
Conversation
"normally, this would point to the class object instance". DBOS is already not doing that, usually inside a DBOS static function 'this' is 'undefined'. |
I'm not sure what this is in reference to |
Try reading it as normally, 'this' would point to the class object instance. DBOS is already giving 'undefined' as 'this' in its static functions. |
I should have updated the initial PR comment. The Function.apply approach didn't work - the 'this' object gets reset when you call into a context method like 'DBOS.workflowID'. Global state is the only option for storing context state so the 'DBOS' statics can retrieve them. I confirmed that the global 'plv8' object is shared between connections. So we hang the DBOS context info off that object where the DBOS context methods can get it. That context info is set and deleted in the generated proc to avoid information leakage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's hold off on merging this until after release
Merge when you feel comfortable, I'm OOF until after release anyway |
This was removed in #697. Re-enabling it and adding tests.
Adds
@DBOS.storedProcedure
(aka v2 stored procedures)Note, plv8 does not support node's
AsyncLocalStorage
API. Since all DBOS functions are static methods in order to support decorators, the stored proc runtime usesFunction.apply
to provide a customthis
object that the stored proc runtime version ofDBOS
context methods accesses. This does change the expected behavior ofthis
object in static methods - normally,this
would point to the class object instance. However, access to the class object instance viathis
isn't very useful to stored procedures anyway. If we feel it's important to maintain access to the class object instance, we can add a property to the customthis
object that references the class object.