-
Notifications
You must be signed in to change notification settings - Fork 5
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
Racing multiple promises #7
Comments
Yeah, I've been thinking about this kind of thing as being their own task type. It's essentially an effect on multiple pending inputs. I don't think that there's anything in the current draft that would prevent this; it just needs a Task description and implementation. |
That makes sense. However what I find curious different judgment was applied to batch task scheduling (which, to some degree, overlaps with #6) E.g. why have a special batch syntax as opposed to a task (that scheduler/runtime can provide) that can take bunch of tasks (or promises with inlined tasks) to run them ? |
From what I understand, that Task (Instruction) would mean to await multiple other Instructions, outputing the awaited result that arrived first. From my understanding of how await works, Invocation would await all of the await inputs before invoking the Instruction with them. I guess we could add to spec a "special" kind of tasks, specifying at Task level that it can start evocation having resolved only some of the awaited inputs. A sort of "await any" logic, at the Task level. Alternatively, perhaps we could have it at the Instruction level?
|
Hmm |
That's a good point! Await seems non-determenistic.Due to the fact that there may be multiple Receipts with different outputs. Also, even when all Receipts are truthful, there may exist different Tasks for the same Instruction, that attenuate "how" differently. Assuming we have agnostic Instructions, there may be non-determenism for await/* when limiting on gas. Perhaps we can achieve determenism at the level of Tasks if we were to bake-into it the exact Receipt "awaited". |
Thought on naming of "await the first fulfilled result". Perhaps a better name for it is E.g., Alice could issue a Task to notify her of any failed Instructions. {"rsc": "mailto:[email protected]",
"op": "msg/send",
"input": {"to": "[email protected]",
"subject": "An Instruction failed",
"body": {"await/any": [{"await/error": {"/": "bafy...instruction1"}},
{"await/error": {"/": "bafy...instruction2"}}]}}} Also, perhaps {"await/any": [{"await/error": {"/": "bafy...instruction1"}},
{"await/error": {"/": "bafy...instruction2"}}]} |
At the moment tasks can be pipelined to run after some set of promises resolve / fail. However there is no way to race multiple tasks and run another task with a winner of the race in the input.
It may be a good idea to have it out of scope in the initial version, but it also may be a good idea how it can be added in the future as it may inform some of the current design.
Perhaps race should be it's own task which could address the use case at hand, but in that case invocation itself needs to support some OR based task submission.
The text was updated successfully, but these errors were encountered: