-
Notifications
You must be signed in to change notification settings - Fork 124
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
feat: Add JavaScript
UDF
#2221
feat: Add JavaScript
UDF
#2221
Conversation
I really dislike the whole pipeline being infected with async. Can we instead make the javascript UDF processor create its own Current-thread scheduler? |
I'm not sure if I understand you correctly. If you are talking about the changes to ProcessorFactory, I think making it async makes sense, because it's already in async context. If you are taking about the Arc held in the udf, I don't have preference. It's just that I'm not used to using multiple runtime in the same process. |
I don't think whether or not something is in an async context dictates whether it should be async, but rather whether it does async work. As a very crude example, you would not write In this case, I prefer the UDF to run on its own runtime, because a UDF will probably be blocking and we don't want it to starve the main runtime. (I don't know if v8 will actually block the tokio runtime if a called js function blocks, but making the UDF create its own runtime also cleans up the API). |
On the first point, On the second point, UDF execution also happens in dedicated thread, so runtime will not be blocked. |
What I'm trying to say is that the trait method should not be async. If one implementation happens to call an API that requires an async environment, we can use I'm willing to be convinced otherwise, so if you disagree, we can have a short sync discussion. |
Example:
Unit tests is not added yet.
The implementation itself is not complicated, however, we have to pass
runtime
around and change some functions toasync
, hence the 1000 lines change.